Hi Forum,
I'm just starting with vb.net and I'm facing a problem that would probably be relatively easy to fix for experienced developers like you.
I'm using the next class to fill my listview
Now my problem:Code:Imports System.Data.SqlClient Public Class ListViewData Public Sub FillListView(ByRef MyListView As ListView, _ ByRef myData As SqlDataReader) Dim lvwColumn As ColumnHeader Dim itmListItem As ListViewItem Dim shtCntr As Short MyListView.Clear() For shtCntr = 0 To myData.FieldCount() - 1 lvwColumn = New ColumnHeader() lvwColumn.Text = myData.GetName(shtCntr) MyListView.Columns.Add(lvwColumn) Next Do While myData.Read itmListItem = New ListViewItem() itmListItem.Text = myData(0) For shtCntr = 1 To myData.FieldCount() - 1 If myData.IsDBNull(shtCntr) Then itmListItem.SubItems.Add("") Else itmListItem.SubItems.Add(myData.GetString(shtCntr)) End If Next shtCntr MyListView.Items.Add(itmListItem) Loop End Sub End Class
I want all the listview columns to be in auto width. I tried adding the next line of code but then only my first column fills my entering listview width. All other columns are not affected!
Can someone help me with this?Code:lvwColumn.Width = -2
Thanks in advance en sorry for my bad english.
Best regards,
Christophe


LinkBack URL
About LinkBacks




Reply With Quote


Bookmarks