Different font in separate listView columns

  • Thread starter Thread starter Robert Misiak
  • Start date Start date
R

Robert Misiak

Is it possible to have a different font in individual listView columns?
When I do something like:

ListViewItem lsi;
....
lsi.SubItems[0].Font = new Font (lsi.SubItems[0].Font,
lsi.Font.SubItems[0].Style | FontStyle.Bold);

The entire line (all columns) of the list appears in bold. I just want the
first item to be bold.

Thank you,
Robert
 
Hello Robert,

Just to be safe - try to carry out the same procedure on any other index
than 0. If this fails, I'm afraid you'll have to resort to custom drawing to
achieve that.
I've reviewed the LVM_SETITEM message documentation, but even this seems to
not allow setting a font for a particular item.
 
Robert said:
Is it possible to have a different font in individual listView columns?
When I do something like:

ListViewItem lsi;
...
lsi.SubItems[0].Font = new Font (lsi.SubItems[0].Font,
lsi.Font.SubItems[0].Style | FontStyle.Bold);

The entire line (all columns) of the list appears in bold. I just want the
first item to be bold.

Hi Robert,

you have to set the ListViewItem.UseItemStyleForSubItems property to false.

If you later change the appearance of the ListViewItem it will
over-write the appearance of the ListViewSubItem permanently. Plan ahead.

Cheers

Arne Janning
 
Arne Janning said:
Robert said:
Is it possible to have a different font in individual listView columns?
When I do something like:

ListViewItem lsi;
...
lsi.SubItems[0].Font = new Font (lsi.SubItems[0].Font,
lsi.Font.SubItems[0].Style | FontStyle.Bold);

The entire line (all columns) of the list appears in bold. I just want the
first item to be bold.

Hi Robert,

you have to set the ListViewItem.UseItemStyleForSubItems property to false.

If you later change the appearance of the ListViewItem it will
over-write the appearance of the ListViewSubItem permanently. Plan ahead.

Cheers

Arne Janning

Thanks, Arne! It works.

Robert
 
Back
Top