Dim width As Double = (ListBox1.ActualWidth / 3) - 2
For Each es As Employees_Structure In myEmp
' Create a new ListBox item for es
Dim li As New ListBoxItem
' Create a Stack panel
Dim sp As New StackPanel
sp.Orientation = Orientation.Horizontal
sp.HorizontalAlignment = HorizontalAlignment.Stretch
' Create a TextBlock to place the info for a column in ListBox
' one for each column
Dim tb1 As New TextBlock
tb1.Text = es.LastName
tb1.Width = width
Dim tb2 As New TextBlock
tb2.Text = es.FirstName
tb2.Width = width
Dim tb3 As New TextBlock
tb3.Text = es.State
tb3.Width = width
' Add the TextBox to the stack panel
sp.Children.Add(tb1)
sp.Children.Add(tb2)
sp.Children.Add(tb3)
' Add the stack panel to the list box item
li.Content = sp
' Add the list box item to the list box
ListBox1.Items.Add(li)
Next
|