How to hide specific row in ListBox control?

  • Thread starter Thread starter Evgeny Zoldin
  • Start date Start date
Hi Evgeny,
AFAIK you can't. The only way to hide a row is to remove it.
 
* "Evgeny Zoldin said:
How to hide (not remove) specified row in ListBox control?

This cannot be done without tricks. Maybe it's possible with an
ownerdrawn listbox, but why not simply remove the line?
 
Simply reload the list view and filter only the rows you want to add
to it. There is no way to hide it otherwise unles you want to spend
days writing an additional project just to hide a row.

Dino
 
Yes, I suppose you could do it by changing the text/foreground color of that
item to simply be the background color (white). The problem there is that if
this item were to be selected, you would then see the white text on the
default blue selection background.

Another thought - You could paint on the text using a brush with a
transparency of 0 rather than the default of 255, e.g.,
Dim InvisibleBrush as Brush = New SolidBrush(Color.FromArgb(0,0,0,0))

Both of these schemes would require you to use the MeasureItem and DrawItem
events.

Don
 
Hi Don,
Both methods even if implemented ok will leave a blank row on the list box.
I wouldn't call this hiding.
 
Thank you all.

I didn't think it so complecated... Even WinAPI
SendMessage( hWnd, LB_SETITEMHEIGHT, rowIndex, 0)
doesn't help here...
So, the simplest way is to reload DataSource

Evgeny


Stoitcho Goutsev (100) said:
Hi Don,
Both methods even if implemented ok will leave a blank row on the list box.
I wouldn't call this hiding.

--
B\rgds
100 [C# MVP]

Don Peters said:
Yes, I suppose you could do it by changing the text/foreground color of that
item to simply be the background color (white). The problem there is
that
if
this item were to be selected, you would then see the white text on the
default blue selection background.

Another thought - You could paint on the text using a brush with a
transparency of 0 rather than the default of 255, e.g.,
Dim InvisibleBrush as Brush = New SolidBrush(Color.FromArgb(0,0,0,0))

Both of these schemes would require you to use the MeasureItem and DrawItem
events.

Don
 
Back
Top