ListBox MinWidthActual workaround?

Does anyone have some tips (or already made some kind of workaround) for ListBox.Column(0).MinWidthActual?

I filed a bug report yesterday but after I did that, I noticed a similar one from 2012 so I guess it’s not going to be fixed anytime soon.

I tried pretty much everything but I either fail to see the logic or there are multiple bugs at the same time.

This is what’s happening now:

Let’s say I have a Listbox with 3 Columns.

ColumnWidths: *,150,150
ColumnsResizable = True

I would like all to have a Minimum Width of 100. So in the Open event, I put:

Me.Column(0).MinWidthActual = 100
Me.Column(1).MinWidthActual = 100
Me.Column(2).MinWidthActual = 100

This more or less works for Columns in the middle but not the first and last ones.

  • When I do this, the last (column(2)) can still be resized smaller than 100.

  • When I make the second (column(1)) as large as possible and then resize the Window smaller, it pushes the first (column(0)) outside the control.
    This is pretty annoying because when a user does this (or maximizes the window, resizes columns and restores the window) the handles to resize the columns are outside the control as well.

I think what should happen is that if a Column is at it’s minimum size and the Window is resized smaller, other Columns that are not at their minimum yet should equally become smaller.
Until they’re all at their minimum size. After that, they all should be equally truncated.

I tried to make workarounds but no luck so far. Maybe someone ran into this before and was able to make it work properly? Or maybe a custom header? (I’ve checked Dave’s custom Listbox header but that’s more if you want other fonts and colors. It doesn’t do resizing.)

True. It seems that there is a problem with “,150,150" and "150,,150”. Only “150,150,*” works correct.

When resizing the control it is up to you to re-calculate all that.

[quote=282680:@Eli Ott]]
When resizing the control it is up to you to re-calculate all that.[/quote]
Why? I’ve set MinWidthActual so it should never go smaller than that or outside the control. Unless all columns are out of space, but then truncate instead.
The Columns are adjusting when the control is resized. Just not correctly.
And besides that, I tried calculating it and set WidthActual of Column(0). That can’t be done because the startpos is outside the control. So you need to adjust Column(1) etc. Pretty much impossible. :confused:

Only the “*” part is resized.

There is a MouseDrag event. You would have to handle column resizing yourself and use the MouseDrag instead.

You can set WidthActual. So if you find it to be over 100, just reset it to 100. You could have a routine to check that.

It should work in MouseDrag or CellBackgroundPaint.