This question is locked. New answers and comments are not allowed.
I am using the following code to build a PanelBar from a database table. For each "FileType" I add a panel and place a ListBox in the panel. This works just fine.
Later in my code I need to access the ListBox to assign its DataSource and load the appropriate data into each ListBox.
See where I come unstuck above. What am I missing?
If I added a listbox to the controls collection of the ContentPanel of the GroupItemElement, why can I not access the ContentPanel of the GroupElement?
e.g.
lst = GroupElement.ContentPanel.Controls(0)
Declan
For Each itemFileTypes In collFileTypes |
If itemFileTypes.IsInUse Then |
Dim newGroupElement As New RadPanelBarGroupElement |
newGroupElement.EnableHostControlMode = True |
newGroupElement.Caption = itemFileTypes.Descr |
Dim lst As New RadListBox |
lst.Name = itemFileTypes.Descr |
lst.Dock = DockStyle.Fill |
lst.Text = itemFileTypes.Type |
newGroupElement.ContentPanel.Controls.Add(lst) |
radPanelBar.Items.Add(newGroupElement) |
End If |
Next |
radPanelBar.Dock = DockStyle.Left |
radPanelBar.ThemeName = "ControlDefault" |
' Set focus to Log panel |
radPanelBar.Items("Log").Focus() ' This throws exception |
Later in my code I need to access the ListBox to assign its DataSource and load the appropriate data into each ListBox.
' For each panel find the listbox and assign its DataSource etc |
' add a listbox event handler for SelectedValueChanged. |
Try |
Dim pnl As RadPanelBarGroupElement |
For Each pnl In radPanelBar.Items |
Dim lst As RadListBox |
'newGroupElement.ContentPanel.Controls.Add(lst) |
' This is where I come unstuck! |
lst = pnl.Items(0) or pnl.ContentPanel.Controls(0) ??? |
With lst |
.ValueMember = "id" |
.DisplayMember = "FileDescription" |
.DataSource = GetFileNamesByType(CType(lst.Text, Integer)) |
'.EmptyRows = True |
AddHandler lst.SelectedValueChanged, AddressOf ListBoxSelectedValueChanged |
End With |
Next |
See where I come unstuck above. What am I missing?
'newGroupElement.ContentPanel.Controls.Add(lst) |
If I added a listbox to the controls collection of the ContentPanel of the GroupItemElement, why can I not access the ContentPanel of the GroupElement?
e.g.
lst = GroupElement.ContentPanel.Controls(0)
Declan