Question

I have a listview inside my split container. My listview contains two columns. One of which I want to be adjusted automatically upon resizing the split container.

Here's a visual perspective:

Normal size

After resize

Resized

As you can see, the columns stay the same sizes ... Even with this code on my split container resize event:

Private Sub sc_Target_Resize(sender As Object, e As System.EventArgs) Handles sc_Target.Resize
    If lvTarget.Columns.Count > 1 Then lvTarget.Columns(1).Width = -2
End Sub

I've also tried to put the column width to -2 on form load ... Didn't change anything. Apparently, -2 width on a listview column should make it autosize. Is what I'm trying to do even possible? Thanks!

Was it helpful?

Solution

I found my solution. I was doing it on the split container resize instead of the actual listview resize.

Here's the solution:

Private Sub lwTarget_Resize(sender As Object, e As System.EventArgs) Handles lwTarget.Resize
    If lwTarget.Columns.Count > 1 Then lwTarget.Columns(1).Width = -2
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top