views:

15

answers:

0

I have a form with the following structure:

Level 1: MainFlowLayoutPanel01

  --------- Level 2 : SubMainFlowLayoutPanel_01
              ------------ Level 3 : SubSubMainFlowLayoutPanel1
                                     ------ UserControl 1
                                     ------ UserControl 2
                                     ------ UserControl 3
                           Level 3 : SubSubMainFlowLayoutPanel2
                                     ------ UserControl 4
                                     ------ UserControl 5
  --------- Level 2 : SubMainFlowLayoutPanel_02
                      ------- UserControl 6
                      ------- UserControl 7

Level 1: MainFlowLayoutPanel02

  --------- Level 2 : SubMainFlowLayoutPanel_01
              ------------ Level 3 : SubSubMainFlowLayoutPanel1

The above arrangement of FlowLayoutPanels was given as a specification; the structure of the above is constructed by a user, by which the user can add a succession of FlowLayoutPanels under which it may contain UserControls or another succession of FlowLayoutPanels. In other words, the user may nest any of the above.

I've tried a recursive approach on this, but I seem to have difficulty getting the layout above saved to a DataSet. I need to be able to determine that the parent of [Level 2 : SubMainFlowLayoutPanel1] is [Level 1: MainFlowLayoutPanel], and that UserControl 1's parent is [Level 3 : SubSubMainFlowLayoutPanel1].

Guess I need help on this; how am I going to save the above layout to a DataSet/DataTable so that when the form loads again, it will recreate the same layout that was saved ?

I was using a recursive function :

Private Sub GetNextControl(ByVal p As Control, ByVal parent As String) For Each ctrl As Control In p.Controls If TypeOf ctrl Is UserControl Then 'save the data structure here Else If ctrl.Controls.Count > 0 Then GetNextControl(ctrl, ParentNode) End If End If Next End Sub

Any theoretical advise is greatly appreciated; I've really hit a brick wall this time.