Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2008 Finding if a control is Enabled

$
0
0
It may sound stupid to ask , but I am forced to ask anyway ... How can we find if a control is Enabled ? I mean succesfully ! Because here's what's going on .
I have a button on a form and when it's pressed it should introduce some text in three separate text boxes . However this has to be done only if a corespondent button next to the text box is enabled . So , in order to make it simplier , lets call the main button MasterButton ( ! ) . Those three text boxes : TextBox1 , TextBox2 and TextBox3 . Next to each of those text buttons there is a silly button called , lets say , LittleButton1 , LittleButton2 and LittleButton3 .
Now , at a given time all of the LittleButtons are Enabled . I know that not only due to the code , but because I see the program running in front of me :) .
The code used , is :

Code:

If LittleButton1.Enabled = True Then
TextBox1.Text = "Bla bla bla"
Else
TextBox1.Text = ""
End If
If LittleButton2.Enabled = True Then
TextBox2.Text = "Blu blu blu"
Else
TextBox2.Text = ""
End If
If LittleButton3.Enabled = True Then
TextBox3.Text = "Blo blo blo"
Else
TextBox3.Text = ""
End If

Therefore , once the the MasterButton is pressed it should fill all of the three text boxes with a text . However there is always one LittleButton that refuses to follow the laws of Physics ! Despite being Enabled , the text button text to it does not receice the text ... Why ?

The only think I have noticed is that this naughty LittleButton (unlike the other two LitleButtons) is on a Tab Control and if its tab is not the current tab , the text box does not receive the text . If , on the other hand , the tab is selected (and therefore the naughty LittleButton is directly visible) then the code runs fine and the Text box next to it receives the text .
But what does the tab has to do with the Enabled property ? In fact I have paused the IDE at that line and actually the naughty button is indeed Enabled even when on a dis-selected tab .

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>