|
-
Dec 6th, 2006, 07:53 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Question on manipulating controls
I will be using n amount of radiobuttons in a form. When a radiobutton is checkekd, I want to display a panel with different controls on it. I am using 1 event handler for each of the radiobuttons. I put the panel name (of panel I want to display) in the "tag" property of the radiobutton.
The question I have is:
How would I do something along the lines of
Code:
(((Panel)(RadioButton)sender).Tag).Visible = true;
I know this won't work, because Tag is a string of the control name and not the actual control itself. If this possible though without looping through each panel to find out if tag matches the panels name to get the control?
Thanks
Last edited by Tool; Dec 6th, 2006 at 09:14 PM.
Reason: Resloved. (Thanks jmcilhinney)
-
Dec 6th, 2006, 08:08 PM
#2
Re: Question on manipulating controls
The Tag property is type Object so it can store anything. That means that rather than storing the name of the control you should store the control itself. That way you can do exactly what you have shown. You can only assign a string to the Tag in the designer so you will need to write code to assign the appropriate Panel to the Tag of the appropriate RadioButton in the Load event handler, assuming that these controls are created at design time anyway.
-
Dec 6th, 2006, 09:13 PM
#3
Thread Starter
Hyperactive Member
Re: Question on manipulating controls
I am creating the radiobuttons through the designer, but writing a few lines of code in the form constructor can handle setting the tag property to the correct control.
Thanks for the hint on the tag property being an object. This will be perfect for my situation. Thanks a million
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
|