469,946 Members | 1,782 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

How to dynamically enable a control and refresh it into the taborder

kea
I have a checkbox and a textbox in a continuous taborder on a form
along with a bunch of other controls. The textbox is disabled.

When I leave the checkbox I want to enable the textbox and move the
focus to it (only if the checkbox.checked=true).

So on the checkbox Leave-event i do the following:
if checkbox.checked=true then
textbox.enabled = true
end if

The result:
the textbox is enabled but the focus is moved to the control after the
textbox.

Question:
Why does the focus not go to the textbox as the textbox is enabled? How
do I get the wanted effect?

I know I can use textbox.focus(), but that gives me problems if the
checkbox is checked and another control subsequent is activated by a
mouseclick. Then the focus will go to the textbox instead of the
control activated by the mouse.

Sep 30 '05 #1
2 2067
DWS
kea,
In the old days I would use the checkchanged event. Here's an example.

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles CheckBox1.CheckedChanged
TextBox1.Enabled = CheckBox1.Checked
End Sub

Good Luck
DWS
"kea" wrote:
I have a checkbox and a textbox in a continuous taborder on a form
along with a bunch of other controls. The textbox is disabled.

When I leave the checkbox I want to enable the textbox and move the
focus to it (only if the checkbox.checked=true).

So on the checkbox Leave-event i do the following:
if checkbox.checked=true then
textbox.enabled = true
end if

The result:
the textbox is enabled but the focus is moved to the control after the
textbox.

Question:
Why does the focus not go to the textbox as the textbox is enabled? How
do I get the wanted effect?

I know I can use textbox.focus(), but that gives me problems if the
checkbox is checked and another control subsequent is activated by a
mouseclick. Then the focus will go to the textbox instead of the
control activated by the mouse.

Sep 30 '05 #2
kea
I tried to simplify my problem but that backfired!

My problem is that I have a groupbox of radiobuttons and each
radiobutton enables/disables/resets some controls. But I do NOT want
this to happen on the specific radiobutton CheckedChanged-event, but
first when I leave the groupbox. Otherwise I get the sitiation that
when I move through the radiobuttons with presses on the arrow key, the
checkChanged event gets fired for each radiobutton I passes. Thereby I
might reset some controls that already contains data and sholud not be
reset..

I want to find out which radiobutton is checked when I leave the
groupBox and then make the enables/disables/resets of the controls. But
if the next control in the taborder is disabled when I enter my
groupbox of radiobuttons, and I enable it in the leave-event of the
groupbox, it does not give focus to the control I just enabled! WHY
NOT???

DWS skrev:
kea,
In the old days I would use the checkchanged event. Here's an example.

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles CheckBox1.CheckedChanged
TextBox1.Enabled = CheckBox1.Checked
End Sub

Good Luck
DWS
"kea" wrote:
I have a checkbox and a textbox in a continuous taborder on a form
along with a bunch of other controls. The textbox is disabled.

When I leave the checkbox I want to enable the textbox and move the
focus to it (only if the checkbox.checked=true).

So on the checkbox Leave-event i do the following:
if checkbox.checked=true then
textbox.enabled = true
end if

The result:
the textbox is enabled but the focus is moved to the control after the
textbox.

Question:
Why does the focus not go to the textbox as the textbox is enabled? How
do I get the wanted effect?

I know I can use textbox.focus(), but that gives me problems if the
checkbox is checked and another control subsequent is activated by a
mouseclick. Then the focus will go to the textbox instead of the
control activated by the mouse.


Oct 2 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by DesignerX | last post: by
reply views Thread by John Crowley | last post: by
9 posts views Thread by TCORDON | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.