|
-
Mar 10th, 2005, 07:33 AM
#1
Re: Control Arrays
However, you have to add further code in order to make controls in the control array respond to events.
I don't live here any more.
-
Mar 10th, 2005, 10:52 AM
#2
Thread Starter
PowerPoster
Re: Control Arrays
 Originally Posted by wossname
However, you have to add further code in order to make controls in the control array respond to events.
Hi, My apologies. I should have selected the full coding when I cut it from a programme.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Aug 5th, 2005, 04:09 PM
#3
Fanatic Member
Re: Control Arrays
Okay.... so where is the rest of the code?
-
Aug 15th, 2005, 05:33 AM
#4
Thread Starter
PowerPoster
Re: Control Arrays
 Originally Posted by epixelman
Okay.... so where is the rest of the code?
It's all there.
You have an array of TextBoxes together with an event handler which responds to any text change in any one of them. If you want to handle other events the example should be easy to follow.
What is your specific problem?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jan 18th, 2006, 08:25 AM
#5
Member
Re: Control Arrays
Thanks for the explanation Taxes, but is it possible to add a handler to the control array itself?
-
Jan 18th, 2006, 10:13 AM
#6
Thread Starter
PowerPoster
Re: Control Arrays
 Originally Posted by trezise
Thanks for the explanation Taxes, but is it possible to add a handler to the control array itself?
No. But what is your problem? You have one eventhandler to handle the same event (e.g. TextChanged) which handles ALL the textboxes. If you are creating the array in the designer, then you have to add the handle for each textbox, but if you create them in code, the appropriate handle is added each time you create the TextBox
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jan 18th, 2006, 01:39 PM
#7
Re: Control Arrays
Hmm. I guess I can understand the want for this, if this is a style you're used to. However, never having had a "control Array" I don't like it. I'm not saying you suck or your code sucks or it's dumb or whatever, but for me, who took one look at VB5 and said "Screw VB" until I saw VB.NET, It just doesn't sit in my belly too well. If I had to do this, I would probably use an arraylist. Ever since the first day I used an arraylist, the word "ReDim" makes me ill.
To me, Arrays are just poor for any kind of dynamic resizing in vb.net. Also, ReDim doesn't work with all dimensions of multi-dimensional arrays. (not cool to me) Honestly, I really don't see the need to have the array of controls.
Use of the tag property, as you mentioned, is a more efficient method in my opinion. You've already got a collection of controls you can enumerate through (Me.Controls) and using the tag property can easily identify them as part of a group.
i.e,
VB Code:
For i As Integer = 1 to 10
WithEvents T as new TextBox
T.Location = New Point(0,i*10)
T.Size = New Size(200,25)
T.Tag = "GUITextBoxes" 'or whatever.
Me.Controls.Add(T)
Next i
'and
For Each Ctl As Control In Me.Controls
If TypeOf(Ctl) Is TextBox AndAlso DirectCast(Ctl,TextBox).Tag = "GUITextBoxes" Then
DirectCast(Ctl,TextBox).Text = "I'm a dynamically Created TextBox"
End If
Next Ctl
So, you can still enumerate through them easily, still add handlers (using the same method you did by casting Sender) and If you want to add another one later, it's no big deal - just add the same tag property, and your current enumeration routines still work.
Bill
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|