Home All Groups Group Topic Archive Search About

Cause Checkbox to lose focus

Author
18 Mar 2006 12:00 AM
OpticTygre
If I create a checkbox dynamically:

Dim NewCheckBox as New Checkbox

Then, I display that checkbox on a form, how can I cause the checkbox to
lose focus after a user clicks on it?

TIA,

-Jason

Author
18 Mar 2006 7:43 AM
R. MacDonald
Hello, Jason,

Where do you want the focus to go?  Just use the Select method on that
control.  E.g.

    DesiredControlToHaveFocus.Select

Cheers,
Randy


OpticTygre wrote:
Show quoteHide quote
> If I create a checkbox dynamically:
>
> Dim NewCheckBox as New Checkbox
>
> Then, I display that checkbox on a form, how can I cause the checkbox to
> lose focus after a user clicks on it?
>
> TIA,
>
> -Jason
>
>
Author
18 Mar 2006 2:21 PM
OpticTygre
Haha...I would like the focus to go "anywhere" but on that checkbox.  The
problem is, the whole form is dynamically generated.  The checkbox's checked
field is bound to an object's boolean variable, and that variable happens to
also be bound to a textbox's enabled property.  The problem is, the
databinding doesn't fire if I check or uncheck the checkbox .....UNTIL I
actually click *off* the checkbox into another textbox on the form or
something.

Does that make sense?

-Jason

Show quoteHide quote
"R. MacDonald" <sci***@NO-SP-AMcips.ca> wrote in message
news:441bba29$0$40635$dbd4b001@news.wanadoo.nl...
> Hello, Jason,
>
> Where do you want the focus to go?  Just use the Select method on that
> control.  E.g.
>
> DesiredControlToHaveFocus.Select
>
> Cheers,
> Randy
>
>
> OpticTygre wrote:
>> If I create a checkbox dynamically:
>>
>> Dim NewCheckBox as New Checkbox
>>
>> Then, I display that checkbox on a form, how can I cause the checkbox to
>> lose focus after a user clicks on it?
>>
>> TIA,
>>
>> -Jason
Author
19 Mar 2006 2:23 PM
R. MacDonald
Hello, Jason,

Yes, I think I understand what you are saying.

What kind of object is it that the CheckBox is bound to?  E.g. does it
have an "Update" method that you can use?  If it does, you could invoke
that in an event handler (such as the OnCheckedChanged procedure that
Armin is suggesting).

If there is no way to update the bound object directly, you could try
using the CheckBox's SelectNextControl method in the handler to force
the focus to the next control.  (But this isn't a very pleasing
solution, because it would introduce a bit of non-standard behaviour in
the user interface.  I would recommend trying to find some sort of
"Update" method solution instead.)

Cheers,
Randy


OpticTygre wrote:
Show quoteHide quote
> Haha...I would like the focus to go "anywhere" but on that checkbox.  The
> problem is, the whole form is dynamically generated.  The checkbox's checked
> field is bound to an object's boolean variable, and that variable happens to
> also be bound to a textbox's enabled property.  The problem is, the
> databinding doesn't fire if I check or uncheck the checkbox .....UNTIL I
> actually click *off* the checkbox into another textbox on the form or
> something.
>
> Does that make sense?
>
> -Jason
>
Author
18 Mar 2006 8:11 AM
Armin Zingler
"OpticTygre" <opticty***@adelphia.net> schrieb
> If I create a checkbox dynamically:
>
> Dim NewCheckBox as New Checkbox
>
> Then, I display that checkbox on a form, how can I cause the
> checkbox to lose focus after a user clicks on it?

Addhandler NewCheckbox.checkedchanged, addressof OncheckedChanged

'...

private sub OnCheckedChanged (ByVal sender As Object, ByVal e As
System.EventArgs)
'...
end sub


Armin