grouping controls together

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Um9iZXJ0IFNtaXRo?=

    grouping controls together

    Hi,
    I have several dropdownList controls on my form and I wish to loop
    through them all and find the selected value and then concatenate them
    together into a string. The problem is I can't find a way to group the
    controls together so that I can loop through them, If I put them in a panel I
    get a compilation error.

    If wish to go
    foreach (Control MyControl in ??????)
    {
    if (typeof(mycontr ol) is dropdownlist)
    {
    mystring = mystring + mycontrol.selec tedvalue

    }
    }

    The problem is with the grouping together of the controls not the string
    concatenation. How can I group the controls so that I can loop through them?
    Thanx in advance

    Robert

  • =?Utf-8?B?MmlvY29uc2VpbCAtIGZhYnJpY2U=?=

    #2
    RE: grouping controls together

    You must regroup all the controls in a Panel for example.

    And then in tour code-behind:

    foreach (Control MyControl in Panel.controls)
    {
    if (typeof(mycontr ol) is dropdownlist)
    {
    mystring = mystring + mycontrol.selec tedvalue
    >
    }
    }

    "Robert Smith" wrote:
    Hi,
    I have several dropdownList controls on my form and I wish to loop
    through them all and find the selected value and then concatenate them
    together into a string. The problem is I can't find a way to group the
    controls together so that I can loop through them, If I put them in a panel I
    get a compilation error.
    >
    If wish to go
    foreach (Control MyControl in ??????)
    {
    if (typeof(mycontr ol) is dropdownlist)
    {
    mystring = mystring + mycontrol.selec tedvalue
    >
    }
    }
    >
    The problem is with the grouping together of the controls not the string
    concatenation. How can I group the controls so that I can loop through them?
    Thanx in advance
    >
    Robert
    >

    Comment

    • Alex Meleta

      #3
      Re: grouping controls together

      Hi Robert,

      You can use Table, Placeholder or such containers for this.

      Regards,
      Alex Meleta
      [Tech Blog: http://devkids.blogspot.com]

      RSHi,
      RSI have several dropdownList controls on my form and I wish to
      RSloop
      RSthrough them all and find the selected value and then concatenate
      RSthem
      RStogether into a string. The problem is I can't find a way to group
      RSthe controls together so that I can loop through them, If I put them
      RSin a panel I get a compilation error.
      RS>
      RSIf wish to go
      RSforeach (Control MyControl in ??????)
      RS{
      RSif (typeof(mycontr ol) is dropdownlist)
      RS{
      RSmystring = mystring + mycontrol.selec tedvalue
      RS}
      RS}
      RSThe problem is with the grouping together of the controls not the
      RSstring concatenation. How can I group the controls so that I can
      RSloop through them? Thanx in advance
      RS>
      RSRobert
      RS>


      Comment

      Working...