locked
Multiple custom controls RRS feed

  • Question

  • User1918001915 posted

     Thank you in advance for any help provided.

    I am looking to create a custom control that will behave (at least constructively) similar to a dropdownlist or a checkboxlist.

    For example, to create a dropdownlist programmitcally you have:

    dim drlist as new dropdownlist
    dim L as listitem.

    L.Text = "A"
    L.Value = "1"
    drlist.add(L)

    The dropdown list then goes through however number of listitems, pulls the properties of each, and renders accordingly.  I am looking at something that may be three tiers (think of adding the above dropdown to a panel programmitcally - panel.add(dropdown) >> dropdown.add(listitem) >> listitem.)

    Can anyone direct me to a page that outlines construction of a control along these lines for structure reference?

    Thanks again.

    Wednesday, May 27, 2009 2:38 PM

Answers

  • User-2106054853 posted

    Hi,

    Actually this is a VB.NET question. To use "For Each" first we should use variable after "in". Another important thing is the class of the variable must implement IEnumerable interface.

    Please ask this question in VB.NET forum, where you can get answer more quickly.

    http://forums.asp.net/36.aspx 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 4:16 AM

All replies

  • User-647234374 posted

    Are you talking about a composite control?

    Wednesday, May 27, 2009 11:58 PM
  • User1918001915 posted

     In some respects, yes.

     But here: http://aspnet.4guysfromrolla.com/articles/102302-1.2.aspx

     There is some extremely clean code that Scott uses in building a custom usercollection control that allows the control to collect items by taking on the arraylist properties.

     Which using that approach has got me all the way up to the final control.

     For the most part I'm able to call each with something like this:

    For each ControlB in ControlA
        'do something at the B level
        For each ControlC in ControlB
             'do something at the C level
        Next
    Next

    My problem is that I am getting a syntax error when I try:

    For Each ControlA in Maincontrol

    (error message from VWD: MainControl is a type can cannot be used as an expression)

    Reason: because Maincontrol is the name of the class.....I'm not sure if I am supposed to declare the additions of ControlA in a property somehow so it can be referenced.

    On the highest level, if I want to have .add capabilities, how do I reference those controls that have been added given that there is not an explicit number by the very nature of the methodology?

     Thanks again for help in this regard.

    Thursday, May 28, 2009 5:10 PM
  • User-2106054853 posted

    Hi,

    Actually this is a VB.NET question. To use "For Each" first we should use variable after "in". Another important thing is the class of the variable must implement IEnumerable interface.

    Please ask this question in VB.NET forum, where you can get answer more quickly.

    http://forums.asp.net/36.aspx 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 4:16 AM