Re: possible to create one control array with different controls?



"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


.



Relevant Pages

  • Re: List Box will not populate the field in the Control Source table
    ... replace the listboxes with unbound textboxes. ... LastName combobox up with 3 columns (don't have to actually see them all ... Then, set the Control ...
    (microsoft.public.access.forms)
  • Re: Auto-populate text boxes based on a query
    ... Alternatively you can set the control source property of the textboxes to ... Organization from a combobox, auto-populate these fields in the form ...
    (microsoft.public.access.forms)
  • Databinding and setting control value in code not working?
    ... Is there an event that must fire if you set the value of an control in code? ... I have a combobox that is bound to a dataset. ... and if it is DBNull, ... I have seen this same behavior with Textboxes. ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Re: Name vom Steuerelement
    ... Private Sub CBOXs_all_MouseEnter(ByVal sender As Object, ... Wenn es sich um Eigenschaften handelt, die von Control geerbt wurden reicht ... End Select ... DirectCast.Text = "ComboBox A" ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Need help with a Custom Function
    ... are 7 textboxes that go with each ComboBox. ... Dim ctlCurrentControl As Control ... Dim myStr As String ...
    (microsoft.public.access.formscoding)

Loading