I am in the transition stage of going from VB6 mentality to VB.NET mentality, and probably am still doing things the old "wrong" way.
Why is the following code not working for me?
oPrintOrders is a DataSet, and PrintOrders is its adapter. I do not think the problem is dataset related.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dc As DataColumn, ch As ColumnHeader
lvJobs.Columns.Clear()'This works OK if I leave the two columns I added at design time!
For Each dc In oPrintOrders.Tables(0).Columns
'This also did not work
'ch = lvJobs.Columns.Add(dc.Caption.ToString, -2, HorizontalAlignment.Left)
ch = New ColumnHeader()
ch.Text = dc.Caption.ToString
ch.Width = -1
ch.TextAlign = HorizontalAlignment.Left
Dim li As ListViewItem
'this works OK if I manually add two columns at design time and do not clear above.
For Each oDR In oPrintOrders.Tables(0).Rows()
li = lvJobs.Items.Add(oDR.Item("JobNumber"))
After clicking on the button, I do not get any column headers at all, although from the vertical scroll bar I can see that the listview has been filled.
I do have
Me.lvJobs.View = System.Windows.Forms.View.Details