By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,335 Members | 1,310 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,335 IT Pros & Developers. It's quick & easy.

Recognising a Tab click

P: n/a
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.

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi

ferg wrote:
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

Nov 13 '05 #2

P: n/a
The following syntax is wrong.
if (this.tabControl1.SelectedIndex = 0)
should be
if (this.tabControl1.SelectedIndex == 0)

Thanks
-----Original Message-----
Hey folks,

I'm new to this malarky, but I can't find anywhere an example ofprogrammatically recognising which tab a user has clicked.
I know it's something to do with the SelectedIndex property of the tabobject, 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' (whetherI have the "this" word in or not).

Can someone tell me what I'm doing wrong?

Thanks,

Ferg.

.

Nov 13 '05 #3

P: n/a
I feel like a real dumbass now. Thanks guys. :-)
"buddy" <bu***@onlinework.com> wrote in message
news:0e****************************@phx.gbl...
The following syntax is wrong.
if (this.tabControl1.SelectedIndex = 0)


should be
if (this.tabControl1.SelectedIndex == 0)

Thanks
-----Original Message-----
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.

.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.