Re: possible to create one control array with different controls?
- From: "CMM" <cmm@xxxxxxxxxx>
- Date: Thu, 23 Feb 2006 20:31:36 -0500
"Rich" <Rich@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6EBE1741-B817-4039-A04B-598771510A9F@xxxxxxxxxxxxxxxx
Hello,
I have 3 textboxes and 1 combobox on a form. On entering the control I
want
to select all the text. I can make an array of textboxes like this:
Dim arrTxt As TextBox() = {txt1, txt2, txt3}
Then I loop through that array
Private Sub onEntering(ByVal sender As Object, ...) Handles _
txt1.Enter,
txt2.Enter, txt3.Enter
CType(sender, TextBox).SelectAll()
End Sub
Is it possible to create a similar control array that I could stuff the
textboxes and the combobox into? If yes, how is this done? What kind of
control object could I use to hold different controls?
Dim arr As Control() = {txt1, txt2, txt3}
or
Dim arr As Object() = {txt1, txt2, txt3}
And how do I check if
sender is a
Textbox or combobox?
If CType(sender, TextBox) = True Then...? is this doable?
If CType(sender, ComboBox) = True Then...?
No, you would use:
If TypeOf sender Is TextBox Then
ElseIf TypeOf sender Is ComboBox Then
Also, make sure your event handler handles the lowest common denominator in
terms of EventArgs. All EventArgs inherit from System.EventArgs... so use
that.
arr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles ...
NOT
arr_Click(ByVal sender As System.Object, ByVal e As
SomeListViewSpecialEventArgs) Handles ...
--
-C. Moya
www.cmoya.com
.
- Follow-Ups:
- Prev by Date: VB 'Phone Home'
- Next by Date: Re: Drawing on panel removes graphics.
- Previous by thread: VB 'Phone Home'
- Next by thread: Re: possible to create one control array with different controls?
- Index(es):
Relevant Pages
|
Loading