philiplcp Posted January 27, 2005 Posted January 27, 2005 Does anyone have idea to replace the 'Me.Controls.Add()' to 'Me.Controls.AddRange()' of the following code. I mean is it possible directly add the 'top' into the 'Me.Controls.AddRange()' dim focus as ToolPanel dim panels as new ArrayList dim top as new ArrayList .................... For Each focus In panels.ToArray focus.Minimize(DockStyle.Top) top.Add(focus) Next .................... For Each focus In top.ToArray : Me.Controls.Add(focus) : Next Quote
RobEmDee Posted January 27, 2005 Posted January 27, 2005 philip: You need to change top to a collection of Controls....I'll try to get the VB right: :p Dim top(panels.Count) As Control Dim count As Int32 = 0 For Each focus In panels.ToArray focus.Minimize(DockStyle.Top) top(count) = CType(focus, Control) count = (count + 1) Next Me.Controls.AddRange(top) Quote Does anyone have idea to replace the 'Me.Controls.Add()' to 'Me.Controls.AddRange()' of the following code. I mean is it possible directly add the 'top' into the 'Me.Controls.AddRange()' dim focus as ToolPanel dim panels as new ArrayList dim top as new ArrayList .................... For Each focus In panels.ToArray focus.Minimize(DockStyle.Top) top.Add(focus) Next .................... For Each focus In top.ToArray : Me.Controls.Add(focus) : Next Quote
Diesel Posted January 27, 2005 Posted January 27, 2005 You don't need to use AddRange, a control has a Controls Collection. Also, if your not using the top variable anywhere else, you don't need it. Dim top As Control For Each focus In panels.ToArray focus.Minimize(DockStyle.Top) top.Controls.Add(focus) Next Me.Controls.Add(top) Quote
Leaders Iceplug Posted January 28, 2005 Leaders Posted January 28, 2005 How about Me.Controls.AddRange(top.ToArray()) ? :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.