VB.Net: resizing a ListBoxView column when changing form

How can I resize a single column with a form so that ListView columns continue to fill the entire form?

0
source share
1 answer

Yes, implement a Resize Listize event handler and calculate the space left for the column. For instance:

Private Sub ListView1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.Resize
    Dim resizeColumn As Integer = 1
    Dim w As Integer = 0
    For column As Integer = 0 To ListView1.Columns.Count - 1
        if column <> resizeColumn then w += ListView1.Columns(column).Width
    Next
    w = ListView1.ClientSize.Width - w - 1 - SystemInformation.VerticalScrollBarWidth
    If w > 0 Then ListView1.Columns(resizeColumn).Width = w
End Sub

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
    ListView1_Resize(Me, EventArgs.Empty)
    MyBase.OnLoad(e)
End Sub
+1
source

Source: https://habr.com/ru/post/1762547/


All Articles