Last post May 29, 2009 04:16 AM by Allen Chen – MSFT
May 27, 2009 02:38 PM|stammer|LINK
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"
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?
May 27, 2009 11:58 PM|nikki_doer_of_things|LINK
Are you talking about a
May 28, 2009 05:10 PM|stammer|LINK
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
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.
May 29, 2009 04:16 AM|Allen Chen – MSFT|LINK
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.