|
-
Jul 29th, 2002, 06:39 PM
#1
Thread Starter
Lively Member
getting an object's label by using sender.text
This is the code i have, but it's not working. what i want is for the label of the object i'm clicking on to appear in the textbox:
Code:
Sub Generic()
Dim Ctl As Control
For Each Ctl In Controls
AddHandler Ctl.Click, AddressOf GenericClick
Next
End Sub
Sub GenericClick(ByVal sender As Object, ByVal e As System.EventArgs)
CustSummaryTxt.Text = sender.text
End Sub
on Form_Load i'm calling Generic(), but the code doesn't work. nothing is displayed in my textbox when i click on a control.
-
Jul 29th, 2002, 10:06 PM
#2
Lively Member
hmm... I just tried your code and it worked fine for some controls but not all of them. Here's a small rundown.
LinkLabel - OK
Button - OK
CheckBox - OK
Label - OK
RadioButton - OK
TreeView - NO
DataGrid - NO
GroupByBox - NO
DateTimePicker - NO
I'm not sure why this is, and I'd imagine there's a work around. Let me play around with this for awhile. I'll let you know if I find anything.
Dr_Evil
Senior Programmer
VS6 EE
VS.NET EA
-
Jul 30th, 2002, 01:00 AM
#3
Thread Starter
Lively Member
thanks for the help. i determined what my problem is. the text of the control will only appear in the textbox as long as the control isn't in a container. so i'm trying to figure out how to get it to appear for my controls in my groupboxes.
I tryed changing Dim Ctl as Control to Dim Ctl as ControlContainer, but i get an exception when i run the program.
Thanks, Brad.
-
Jul 30th, 2002, 08:30 AM
#4
Lively Member
Try this.
Code:
Dim objControl As Control
For Each objControl In Me.GroupBox1.Controls
AddHandler objControl.Click, AddressOf GenericClick
Next
Dr_Evil
Senior Programmer
VS6 EE
VS.NET EA
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
|