Hi,
I am trying to build a function to create a collection of all textboxes with in a form. Maybe someone can tell me what is wrong here
in module1 i have...
Public Function AllTextBoxesInControlCollection(ByVal CollectionToScour As Control.ControlCollection, ByVal owner As Control) As Control.ControlCollectionAllTextBoxesInControlCollection =
New Control.ControlCollection(owner) For Each ctrl As Control In CollectionToScour If TypeOf (ctrl) Is TextBox ThenAllTextBoxesInControlCollection.Add(ctrl)
End If Next End Functionto test the function i place a 3 textboxes on a form1 and have the following in my form1.load.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim coll As Control.ControlCollection = Module1.AllTextBoxesInControlCollection(Me.Controls, Me) For Each tb As TextBox In collMsgBox(tb.Name)
' show me all the controls so i know if my function is working correctly Next End Sub
When i step through the function it seems to be adding all 3 controls to the collection, however form1's collection seems to be empty. I wasn't sure what to put as the new collection's owner, so i just passed form1 to it. Can anyone help shed light on this

newbie building my first custom control collection
KPC
Actually what I am trying to do is build my own control collection. The example i am using above is just a simple example of how I might use it, but I have other reasons for trying this.
I'm trying to figure what I am doing wrong in the above short example
Steveiwonder
Dave;
Here is a link to to a post where I had answered a similiar question. In your case, you would simply add the textbox to a collecition instead of an array as I did. Let me know if you still can't get it going.
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=316957&SiteID=1
SteveCook
In case you're wondering why I'm building this function. I want to apply the following to each text box on many of my forms, to accomodate users who like to hit enter after they type something. I will cycle through the textboxes, applying
addhandler textbox.keypress, addressof MapEnterToTab on each textbox
Private Sub MapEnterToTab(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) If e.KeyChar = Chr(13) Then ' take the enterSendKeys.Send(Chr(9)) ' and make it a TAB instead
e.Handled =
True End If End Subjoseangel_yanez
Any comments Good, bad or ugly
KelleyBryant
Is it possible to make this work
Base64
anybody