Hello my fellow Daniwebbers, I have a modest question for you.
I have a panel, which contains child panels.
I have code the alows the user to delete the selected panel, but can't figure out how to refresh the parent panel with the deleted panel gone. When I use the refresh, the empty space is still there... So, I wrote a block of code that is supposed to "shift" all of the panels up to the deleted panels position. But when the code is executed, the panel to delete is deleted...along with everything above it. :S
Here is my code.
'Allows the user to delete the currently selected tab on the tab control. Try If Not (selectedPanel Is Nothing) And Not (myPanels Is Nothing) Then For i = 0 To myPanels.Count - 1 If myPanels(i).pnl Is selectedPanel Then For j = i + 1 To myPanels.Count - 1 If j <> myPanels.Count Then myPanels(j).loc = myPanels(i).loc myPanels(i).pnl = myPanels(j).pnl j += 1 End If Next selectedPanel.Dispose() ImagePanel.Controls.Clear() ImagePanel.Refresh() End If Next For i = 0 To myPanels.Count - 1 If Not (myPanels(i).pnl Is Nothing) Then ImagePanel.Controls.Add(myPanels(i).pnl) End If Next Return End If Catch ex As Exception MsgBox("Exception from: " & ex.Source & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace.ToString, MsgBoxStyle.OkOnly) Return End Try
'Declaration of myPanels dim myPanels(100) as panelArray 'Declaration of panelArray Public Structure panelArray Public pnl As Panel Public loc As System.Drawing.Point Public siz As System.Drawing.Size End Structure