Sub LoadTrucks()
Try
'objective:
'open 10 documents inside of a RadDock in a 5 over 4 layout
'populate the RadDock DocumentWindows with a windows form
'Retrieve a dataset of objects that will represent the 9 forms that we want to open
Dim oDT As DataTable = SPs.FP_FPLoad_SEL_Committed2(Me.btnDispatchOffice.Text, App.Database).getTable
'the code is flexible, it will dispaly the documents evenly split. These variables facilite that
Dim intRowCount As Int16 = oDT.Rows.Count
Dim intCount As Int16 = 0
Dim intCount2 As Int16 = 0
'Loop through the objects that we want to open in DocumentWindows. In our example there are 9 items, but any amount will work
For Each oRow As DataRow In oDT.Rows
'declare a document window
Dim oDocumentWindow As New DocumentWindow
'set window properties
oDocumentWindow.Text = oRow("vchrTruck")
'declare the form that we want inside the window
Dim frm As New Dispatch.Truck2(oRow("vchrTruck"), Me.btnDispatchOffice.Text, Dispatch.Truck2.FormTypeType.Delivery)
frm.TopLevel = False
frm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
frm.Show()
'add the form to the DocumentWindow
oDocumentWindow.Controls.Add(frm)
RadDock1.AddDocument(oDocumentWindow)
intCount += 1
Next
'get the mid point in the object count
intCount2 = intCount / 2
'reset the counter
intCount = 0
'loop again, and move the DocumentWindows that we created above into position
For Each oRow As DataRow In oDT.Rows
Select Case intCount
Case 0
'dock the first window 'top'
RadDock1.DockWindow(RadDock1.DockWindows.DocumentWindows(0), DockPosition.Top)
Case Is < intCount2
'the next 4 get docked 'right'
Me.RadDock1.DockWindow(RadDock1.DockWindows.DocumentWindows(intCount), RadDock1.DockWindows.DocumentWindows(intCount - 1), DockPosition.Right)
Case intCount2
'doc the 6th window 'bottom'
Me.RadDock1.DockWindow(RadDock1.DockWindows.DocumentWindows(intCount), DockPosition.Bottom)
Case Else
'the next 3 get docked 'right'
Me.RadDock1.DockWindow(RadDock1.DockWindows.DocumentWindows(intCount), RadDock1.DockWindows.DocumentWindows(intCount - 1), DockPosition.Right)
End Select
intCount += 1
Next
Catch ex As Exception
ErrorHandler.globalErrorHandler(ex, True)
End Try
End Sub