Results 1 to 3 of 3

Thread: [RESOLVED] Question on manipulating controls

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    midewest u.s.
    Posts
    275

    Resolved [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)

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    midewest u.s.
    Posts
    275

    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
  •  



Click Here to Expand Forum to Full Width