I have created a windows forms app that is very complex. What I am trying to do now is if different buttons are clicked to disable some panels but shift all the other panels underneath of it up so it looks in order. I am having such a hard time with this. I wanted to develop a function that passes in a Panel that is getting disabled and a list of all other panels underneath of it and using recursion rearrange all the panels. This function works but it does not take in consideration if one panel has a height bigger than the other it leaves extra spaces between the two panels. Any help would be much appreciated.
Public Sub whatever(ByVal panel As Panel, ByVal list As List(Of Panel))
Dim temppanel As Panel = New Panel()
For Each item As Panel In list
temppanel.Location = New Point(temppanel.Location.X, item.Location.Y)
item.Location = New Point(item.Location.X, panel.Location.Y)
list.Remove(item)
whatever(temppanel, list)
If list.Count = 0 Then
Exit For
End If
Next
End Sub
Image
A FlowLayoutPanel probably is more appropriate for this, but here is a general method to do what I think you are looking for:
Replace
Mewith the parent container if these panels are not inMe.If using .net 2.0 where LINQ is not available, the function would look something like this: