Click here to Skip to main content
15,914,820 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: VB.NET 2005 TabStripPanel Pin
Daniel Grunwald28-Dec-05 11:51
Daniel Grunwald28-Dec-05 11:51 
GeneralRe: VB.NET 2005 TabStripPanel Pin
fuel2run28-Dec-05 23:44
fuel2run28-Dec-05 23:44 
QuestionNetwork question (beginner) Pin
Derek G28-Dec-05 5:58
Derek G28-Dec-05 5:58 
AnswerRe: Network question (beginner) Pin
Dave Kreskowiak28-Dec-05 6:26
mveDave Kreskowiak28-Dec-05 6:26 
QuestionDeleting/Clearing programmically created controls Pin
Hmmkk28-Dec-05 3:46
Hmmkk28-Dec-05 3:46 
AnswerRe: Deleting/Clearing programmically created controls Pin
Dave Kreskowiak28-Dec-05 4:29
mveDave Kreskowiak28-Dec-05 4:29 
GeneralRe: Deleting/Clearing programmically created controls Pin
Hmmkk28-Dec-05 4:44
Hmmkk28-Dec-05 4:44 
GeneralRe: Deleting/Clearing programmically created controls Pin
Dave Kreskowiak28-Dec-05 5:01
mveDave Kreskowiak28-Dec-05 5:01 
Looping through 10 different names, and the controls for each name, is very slow. I would suggest naming your panel controls that are removable with a common name prefix and a number and just going through the controls array once. It looks like you already have something like this, but just to be sure...

But, you're getting the IndeoxOutORangeException because when you Dispose the control, the number on controls in the collection is reduced by one, making the top end of your loop greater than the new number of controls in the Control array. The solution is deceptively easy -- Start and the end of the array and work your way back!
For i As Integer = Me.Controls.Count - 1 To 0 Step -1
    If Me.Controls(i).Name.StartsWith("pnlThing") Then
        Me.Controls(i).Dispose()
    End If
Next

Note, you cannot use a For Each enumeration in this loop because of the same problem! Modifying the size of a collection during an enumeration is, in most cases, not allowed!

RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome


-- modified at 11:02 Wednesday 28th December, 2005
GeneralRe: Deleting/Clearing programmically created controls Pin
Hmmkk28-Dec-05 5:15
Hmmkk28-Dec-05 5:15 
GeneralRe: Deleting/Clearing programmically created controls Pin
Dave Kreskowiak28-Dec-05 5:50
mveDave Kreskowiak28-Dec-05 5:50 
QuestionRe: Deleting/Clearing programmically created controls Pin
Hmmkk28-Dec-05 6:41
Hmmkk28-Dec-05 6:41 
AnswerRe: Deleting/Clearing programmically created controls Pin
Dave Kreskowiak28-Dec-05 13:14
mveDave Kreskowiak28-Dec-05 13:14 
GeneralRe: Deleting/Clearing programmically created controls Pin
Hmmkk28-Dec-05 14:58
Hmmkk28-Dec-05 14:58 
GeneralRe: Deleting/Clearing programmically created controls Pin
Dave Kreskowiak28-Dec-05 16:06
mveDave Kreskowiak28-Dec-05 16:06 
QuestionHowTo: HTML_2_Image Pin
Dredy28-Dec-05 0:58
Dredy28-Dec-05 0:58 
Questionstill excel remains in memory Pin
jith - iii27-Dec-05 22:54
jith - iii27-Dec-05 22:54 
QuestionHow to communicate with serial port in VB.NET Pin
kusikue27-Dec-05 22:46
kusikue27-Dec-05 22:46 
AnswerRe: How to communicate with serial port in VB.NET Pin
Dave Kreskowiak28-Dec-05 4:34
mveDave Kreskowiak28-Dec-05 4:34 
GeneralRe: How to communicate with serial port in VB.NET Pin
WillemM28-Dec-05 8:55
WillemM28-Dec-05 8:55 
QuestionGet previously active window?? Pin
matsnas27-Dec-05 22:29
matsnas27-Dec-05 22:29 
AnswerRe: Get previously active window?? Pin
Dave Kreskowiak28-Dec-05 4:46
mveDave Kreskowiak28-Dec-05 4:46 
QuestionWinForm LifeCycle.. Pin
HakunaMatada27-Dec-05 19:52
HakunaMatada27-Dec-05 19:52 
AnswerRe: WinForm LifeCycle.. Pin
Dave Kreskowiak28-Dec-05 4:37
mveDave Kreskowiak28-Dec-05 4:37 
GeneralRe: WinForm LifeCycle.. Pin
HakunaMatada28-Dec-05 17:24
HakunaMatada28-Dec-05 17:24 
GeneralRe: WinForm LifeCycle.. Pin
Dave Kreskowiak29-Dec-05 5:18
mveDave Kreskowiak29-Dec-05 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.