Results 1 to 5 of 5

Thread: Finding tab based on tag *resolved*

  1. #1

    Thread Starter
    Hyperactive Member Colonel Klink's Avatar
    Join Date
    Aug 2002
    Location
    Gold Coast, Australia
    Posts
    329

    Finding tab based on tag *resolved*

    im making an irc client...

    here is the scenario

    when you for example join a channel, it adds a tabpage to the tabcontrol. when this happens, i add to the newly created tabpage in its tag the channel name.

    now with that in mind... say i join 2 channels... #channel1 and #channel2... the page's tag for #channel1 is #channel1 and the same for #channel2

    now, when i recieve an message event, i need to know which tabpage to send the text to via its tag, and output the text to a textbox on that tab

    how do i do that?

    something like... if tabpage.tag = "#channel1" then print "blah" to txtbox on tabpage where tabpage.tag = "#channel1"
    Last edited by Colonel Klink; Sep 18th, 2003 at 07:33 AM.

  2. #2
    Lively Member
    Join Date
    Sep 2002
    Posts
    100
    Hey Colonel,

    I'm not quite sure exactly how to do this but try creating a method that auto creates a channel window, by doing something like the following. There is another method that is more complicated, but here is a possible solution.


    Code:
    System.Collections.Specialized.NameValueCollection chatareatext;
    
    private void CreateWindow(string channelname)
    {
    	string chattext = "";
    	chatareatext.Add(channelname, chattext);
    }
    
    private void TabChange(int i)
    {
    	tbChatArea = (string) chatareatext[i];
    }
    
    private void ReceivedChatRoomText(string chatroom, string text)
    {
    	for (int i  = 0; i < chatareatext.Count; i++)
    	{
    		if (chatarea.Keys[i] == chatroom)
    		{
    			chatarea[i] += text;
    			if (tabcontrol.selectedindex == i)
    			{
    				textchatarea.Text += text;
    			}
    			return;
    		}
    	}
    
    	// if not
    	CreateWindow(chatroom);
    
    	// now it exists, recall self to update
    	ReceivedChatRoomText(string chatroom, string text);
    }





    Mitchel

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    You are going to do something like this:
    Code:
    string myString = "#Channel1";
    
    foreach(TabPage page in TabControl.TabPages)
    {
    	if(page.Text == myString)
                    {
                         // page is your tab page, do your code here.
                    }
    }

  4. #4
    Lively Member
    Join Date
    Sep 2002
    Posts
    100
    Hellswraith with the simple solution!

    Hey hell I wanted to use that but I can't figure out..to create the new tab page, whats the easiest way without using my own method to create a new tab page...I want to create it in the designer, then copy it over to create a new page...probably not possible like that..


    Mitchel

  5. #5

    Thread Starter
    Hyperactive Member Colonel Klink's Avatar
    Join Date
    Aug 2002
    Location
    Gold Coast, Australia
    Posts
    329
    omg hellswraith you little ripper!

    thanks mate

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width