Listbox questions

  1. Is there a way to bold the text in the header row (not the table rows)?

  2. Is there a way to get an event triggered if the user resizes a column? I’m supplying widths to all columns and so would like to add/subtract width from the rightmost column when the user resizes an earlier one.

  3. I see I can use the CellPaintText event to put an image into cells other than the first one. This seems a bit clumsy as the resulting image stays where it is drawn - its position within the cell doesn’t respect the cell’s alignment. Is this the only method? In addition, this forces me to put some of the logic into this event handler. This logic determines which image I’m going to draw, for example. So either I use globals to pass this information to the event handler or I put it into the cell itself, read and erase it from the cell, and then decide what to draw. What about a new listbox method: listbox.CellPicture(row, column) = somePicture

[quote=222686:@Tim Streater]1) Is there a way to bold the text in the header row (not the table rows)?
[/quote]
Not built in. You can suppress the headers and put a second listbox above the first as a headers-only list, or put a
canvas above the listbox and draw your own headers.

[quote]2) Is there a way to get an event triggered if the user resizes a column? I’m supplying widths to all columns and so would like to add/subtract width from the rightmost column when the user resizes an earlier one.
[/quote]
Again, not built in. You can detect a change in column width in CellBackgroundPaint and raise your own event.

[quote]3) I see I can use the CellPaintText event to put an image into cells other than the first one. This seems a bit clumsy as the resulting image stays where it is drawn - its position within the cell doesn’t respect the cell’s alignment. Is this the only method? In addition, this forces me to put some of the logic into this event handler. This logic determines which image I’m going to draw, for example.
[/quote]
That is correct.

[quote]So either I use globals to pass this information to the event handler or I put it into the cell itself, read and erase it from the cell, and then decide what to draw.
[/quote]
You can put the image in the CellTag.

Much easier way is to make the ListBox itself bold (i.e. ListBox1.Bold = True) and in the CellTextPaint event add the line:

g.Bold = False

The Header will be bold and the cell text will not.

Thanks, guys. TimH’s suggestion of the CellTag was also helpful. It would seem that the event is triggered if I put something in the CellTag, although I had understood from the docs that one had to write something into the cell (even if only nothing).