How to hide specific row in ListBox control?

E

Evgeny Zoldin

Hi ALL.

How to hide (not remove) specified row in ListBox control?

Thanks
Evgeny
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi Evgeny,
AFAIK you can't. The only way to hide a row is to remove it.
 
H

Herfried K. Wagner [MVP]

* "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?
 
D

Dino Buljubasic

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
 
D

Don Peters

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
 
S

Stoitcho Goutsev \(100\) [C# MVP]

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

Evgeny Zoldin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top