Toolbar, tabcontrol and switch (x) select statement

J

JH

I got a toolbar with four toolbarButtons. Moreover I have a tabcontrol with
four tabpages. For each toolbarbutton click,I want a specific tabpage to
show. But I am having a problem even when I use the show(), focus() or
BringTofront() methods.
Please somebody see the simple code below and find where I am getting it all
wrong.
Thanks

private void tbrMain_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{



string x = e.Button.ImageIndex.ToString();

switch(x)


{


case "2":



// this.tabControl1.TabPages[0].Show() ;

// this.tabControl1.TabPages[0].Focus();

this.tabControl1.TabPages[0].BringToFront();


break;


case "3":


//MessageBox.Show("second ");

//this.tabControl1.TabPages[1].Show();
this.tabControl1.TabPages[1].BringToFront();


break;


case "4":


//tabControl1.TabPages[2].Show() ;

this.tabControl1.TabPages[2].BringToFront();


break;

case "11":

this.tabControl1.TabPages[3].BringToFront();


break;



default:



break;


}
 
J

JH

I got it. I should have done the following code. And it works fine now.

this.tabControl1.SelectedTab = this.tabPage2 ;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top