|
-
Aug 28th, 2003, 09:55 AM
#1
Thread Starter
Hyperactive Member
Since there are no more control arrays...
If I have some RadioButtons and want to change all of their text properties using a subroutine, but how do I loop thru all of them?
Thanks.
-
Aug 28th, 2003, 10:39 AM
#2
-
Aug 28th, 2003, 11:22 AM
#3
Addicted Member
Use the tag property of the control. In this case I've set the tag of the group of radiobuttons to "RB1".
VB Code:
Dim CTRL As Control
For Each CTRL In Me.Controls
If TypeOf (CTRL) Is RadioButton Then
If CTRL.Tag = "RB1" Then
CTRL.Text = "RB1"
End If
End If
Next
-
Aug 28th, 2003, 12:30 PM
#4
Thread Starter
Hyperactive Member
Yeah I already hardcoded EACH of the text properties and tags. But each time I click one of the Radios I get a sub with the name of the Radio i.e.
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
End Sub
So my question now is,
HOW THE HELL DO I WRITE A SUB THAT 'KNOWS' WHICH RADIOBUTTON WAS SELECTED?
Sorry people Im not crabbing at yall but this is frustrating. I just started yesterday with VB.Net
-
Aug 28th, 2003, 12:46 PM
#5
Addicted Member
You can write one onClick handler for each "group" of radiobuttons that sets a variable to which one is selected.
PHP Code:
Private rdbSet As System.Windows.Forms.RadioButton
Private Sub radiobutton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles rdbBottom.Click, rdbFill.Click, rdbLeft.Click, rdbRight.Click, rdbTop.Click, rdbNone.Click
rdbSet = CType(sender, RadioButton)
ApplyChanges()
End Sub
Private Sub ApplyChanges()
'Apply Docking settings - one only
If rdbSet Is rdbNone Then
btnDemo.Dock = System.Windows.Forms.DockStyle.None
ElseIf rdbSet Is rdbTop Then
btnDemo.Dock = System.Windows.Forms.DockStyle.Top
ElseIf rdbSet Is rdbLeft Then
btnDemo.Dock = System.Windows.Forms.DockStyle.Left
ElseIf rdbSet Is rdbBottom Then
btnDemo.Dock = System.Windows.Forms.DockStyle.Bottom
ElseIf rdbSet Is rdbRight Then
btnDemo.Dock = System.Windows.Forms.DockStyle.Right
Else ' The default is: if (rdbSet is rbFill)
btnDemo.Dock = System.Windows.Forms.DockStyle.Fill
End If
End Sub
-
Aug 28th, 2003, 01:44 PM
#6
Thread Starter
Hyperactive Member
Oh man! I got it working. Thanks a lot!
-
Aug 28th, 2003, 03:08 PM
#7
Thread Starter
Hyperactive Member
I got it working but I have a few q's
what does ByVal e As EventArgs pass to the function?
what does the CType function return?
-
Aug 28th, 2003, 04:01 PM
#8
Addicted Member
I'm not a guru, but these are my personal thoughts about it.
>> what does ByVal e As EventArgs pass to the function?
I think this is just the actual event, sorta like having the location where (x,y) the event happened, which mouse button was clicked, etc.
>> what does the CType function return?
RadioButton - The CType function returns type of the second parameter.
Sender is just an object, so in order to get radiobutton properties we need to convert it to a radiobutton. If Sender was a textbox, this line of code would probably error.
-
Aug 29th, 2003, 08:16 AM
#9
Thread Starter
Hyperactive Member
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
|