Hiding the rightmost vertical grid line in a listbox

When I turn on vertical grid lines in a Listbox, it places a grid line at the right of the last column that is also the rightmost edge of the listbox. The left column does not have a similar grid line at the left edge of the listbox. I think this looks silly. I’ve noticed that is I set the column widths using percentages and allow the percentage to exceed 100, then the last grid line disappears. But this seems like a kludge to me and it also will not work when the last column uses an * to specify the width.

Is there another (simple) way to hide the rightmost vertical grid line of a listbox?

Feature Request or Bug Report (depending on how you look at it). I personally think it’s a bug in that the first cell edge and last cell edge are the listbox edges and don’t require a grid line to delineate the edges.

You can always turn them off and do your own in the CellbackgroundPaint event. I’ve found I have a lot more control over everything there, and I really don’t see a performance hit (although when I need a really big grid I use the Einhugur StyleGrid, so maybe I am just not seeing it).

what did u do with CellbackgroundPaint, Merv??

Just simple stuff like this:

g.ForeColor = &c222222 Select Case column Case 0, 2, 6 g.PenWidth = 1 g.DrawLine 0, 0, 0, Me.Height Case 1, 7 g.PenWidth = 2 g.DrawLine 0, 0, 0, Me.Height End Select

You can use different colored borders, different line thicknesses, etc… I have another grid that I draw a rectangle in the currently selected cell so that it behaves more like Excel, I’ll post in a second. Really easy to implement, the ListBox is pretty flexible.

This draws a focus rectangle in the current cell like Excel. xColumn is a property in my subclassed ListBox that holds the current column:

[code] // draw focus rectangle
If column = xColumn Then
If row = ListIndex Then

    // inner background color
    g.ForeColor = &cFFFFBB
    g.FillRect 2, 2, g.width - 1, g.height - 1
    
    // outer ring
    g.ForeColor = &c0000EE
    g.DrawRect 0, 0, g.width - 1, g.height - 0
    g.ForeColor = &c000099
    g.DrawRect 1, 1, g.width - 3, g.height - 2
    
  End If
End If

Return True
[/code]

you can do similar stuff with the CellTextEvent, all pretty easy stuff that has been posted quite a few times on the old Real forums.

merv, amazing stuff.

Nah, this is simple stuff, you want amazing ListBox tidbits, pick Karen’s brain. :slight_smile:

Never thought of using CellBackgroundPaint. Thanks!

Maybe you should start a conversation on HOW TO WORK WITH LISTBOX

Basically it’s just reading all listbox the docs, understanding the API and then applying a bit of ingenuity, you can make it do a lot of things with some work.