List Info

Thread: Get a DataGrid row's current height




Get a DataGrid row's current height
user name
2006-04-14 19:19:20
To answer my own question: A HitTestInfo.Row greater than -1
lets you
know you're own a row in the grid. Then get the height of
the cell in
the first column.

if (hti.Row >= 0) {
        int currentRowHeight = 
                grid.GetCellBounds(hti.Row, 0).Height;
        Console.WriteLine(currentRowHeight);
} 

-----Original Message-----
From: Discussion forum for developers using Windows Forms to
build apps
and controls [mailtoOTNET-WI
NFORMSDISCUSS.DEVELOP.COM] On Behalf Of
Gray, Lee P.
Sent: April 14, 2006 9:08 AM
To: DOTNET-WINFORMSDISCUSS.DEVELOP.COM
Subject: [DOTNET-WINFORMS] Get a DataGrid row's current
height

I would like to allow the user to customize the
PreferredRowHeight for
each TableStyle in a DataGrid.  I was thinking of creating a
context
menu where after resizing a row's height, if you
right-clicked that row,
the menu would have an option to save that row's height as
the default
for that grid.

If the user clicks on a cell, I can get the row and column
from a
HitTestInfo object, then get the *cell's* height with
GetCellBounds.
But what if the user clicks a rowheader?

Is there any other way to detect a grid row's height?

Thanks,
Lee
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )