Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with alternate row colouring in the Listview

1 view
Skip to first unread message

Ishan Bhalla

unread,
Jul 2, 2002, 4:34:45 AM7/2/02
to
I am using alternate row colouring in the List view and have a few
problems.

The concept is based on the concept of drawing a number of coloured,
transparent picture boxes on the list view.

To accurately place the picture boxes over the list view one has to take
into account the height of the font.

Getting the height of the font has the following problems:
1. Different fonts have different heights.
2. The same font may not scale in a linear manner. i.e. - Size 16 may not be
double the height size 8.
3. Some fonts may not have certain sizes. E.g.: Arial does not have a size
10. If the user sets the font size to 10, windows overrides it and sets it
to 9.75.

All these problems boil down to the fact that it is difficult to find a
constant that can be multiplied to the font size to get the desired effect.

So the problem is how to get the height of the font?


Peter Chapman

unread,
Jul 2, 2002, 4:53:17 AM7/2/02
to
Have a look at the winapi function GetTextMetrics it
returns loads of info on the current font including its
height. Have you considered subclassing the listview and
using the GDI to draw it yourself - In the long run this
is going to give you more flexibility and speed than a
picture box hack.

Peter

>.
>

John Rischmiller

unread,
Jul 2, 2002, 6:53:43 AM7/2/02
to
Check out the TextHeight method. Even if your control doesn't support it,
set the forms Font property to your controls Font property, and run the
TextHeight method on your selected text. There's also a TextWidth method.

--
Regards - John Rischmiller.
mailto:jri...@btinternet.com
"Ishan Bhalla" <ishan...@hotmail.com> wrote in message
news:#9dEbMaICHA.2280@tkmsftngp12...

Jan Hyde

unread,
Jul 2, 2002, 8:17:00 AM7/2/02
to
why not just use a grid control?

"Ishan Bhalla" <ishan...@hotmail.com>'s wild thoughts
were released on Tue, 2 Jul 2002 14:04:45 +0530 bearing the
following fruit:


--

The first scientists who studied fog were mistified. (Mike Bull)

Ken Halter

unread,
Jul 2, 2002, 10:57:56 AM7/2/02
to
Did you start with one of these?

Creating a Ledger-Style Listview Report Background
http://www.mvps.org/vbnet/index.html?code/comctl/lvledger.htm

or

Creating Ledger-Style Listview Report Background with Custom Height
http://www.mvps.org/vbnet/index.html?code/comctl/lvledgerrows.htm

--
Ken Halter
MS-MVP-VB
http://www.vbsight.com
http://www.vbsight.com/MultiColumn.htm
Please keep it in the groups..

0 new messages