Recognising a Tab click

F

ferg

Hey folks,

I'm new to this malarky, but I can't find anywhere an example of
programmatically recognising which tab a user has clicked.
I know it's something to do with the SelectedIndex property of the tab
object, but I can't get it into an "if" statement without it complaining.

Here's what I have...

private void fclsTabs_Load(object sender, System.EventArgs e)

{


if (this.tabControl1.SelectedIndex = 0)

txtTextBoxMain.Text = "Tab 1";

}

This complains with "Cannot implicitly convert type 'int' to 'bool' (whether
I have the "this" word in or not).

Can someone tell me what I'm doing wrong?

Thanks,

Ferg.
 
?

=?ISO-8859-2?Q?Marcin_Grz=EAbski?=

Hi
Hey folks,

I'm new to this malarky, but I can't find anywhere an example of
programmatically recognising which tab a user has clicked.
I know it's something to do with the SelectedIndex property of the tab
object, but I can't get it into an "if" statement without it complaining.

Here's what I have...

private void fclsTabs_Load(object sender, System.EventArgs e)

{

// if (this.tabControl1.SelectedIndex = 0)

// try this:

if (this.tabControl1.SelectedIndex == 0)
txtTextBoxMain.Text = "Tab 1";

}

This complains with "Cannot implicitly convert type 'int' to 'bool' (whether
I have the "this" word in or not).

Can someone tell me what I'm doing wrong?

In c# (like in c, c++, java) "is equal" operator is "==" (not "=")

Marcin Grzêbski
 

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