VB.NET - How to i identify one of multiple usercontrol instances?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Joca
    New Member
    • Jul 2008
    • 10

    VB.NET - How to i identify one of multiple usercontrol instances?

    I've made a form that shows a variable number of instances of a usercontrol depending of a number from a database. Every usercontrol has a checkbox, but how do i know which one is selected if they all have the same name?
  • yasirmturk
    New Member
    • Aug 2008
    • 15

    #2
    you can assign index number in some pattern to the controls

    e.g
    chk_0
    chk_1
    chk_2
    chk_3

    Thanx

    Originally posted by Joca
    I've made a form that shows a variable number of instances of a usercontrol depending of a number from a database. Every usercontrol has a checkbox, but how do i know which one is selected if they all have the same name?

    Comment

    • Joca
      New Member
      • Jul 2008
      • 10

      #3
      Thanks for the quick reply. You mean using that "identifier " in the tag property of the control? I'll give it a shot. Thanks again.

      Comment

      • yasirmturk
        New Member
        • Aug 2008
        • 15

        #4
        Code:
        void AddControl(int index, Panel container)
        {
        CheckBox cb = new CheckBox();
        cb.Name = "chk_"+index;
        container.Controls.Add(cb);
        }

        Originally posted by Joca
        Thanks for the quick reply. You mean using that "identifier " in the tag property of the control? I'll give it a shot. Thanks again.
        Last edited by yasirmturk; Aug 11 '08, 01:38 PM. Reason: mistake

        Comment

        • Joca
          New Member
          • Jul 2008
          • 10

          #5
          Thanks alot mate! I managed to get it working.

          Comment

          Working...