DataGrid Column Position

bufer24

Active member
Joined
Mar 27, 2008
Messages
35
Programming Experience
3-5
Hello, I have a datagrid in my project and I want to place label controls above each of its columns and those labels should stay above each column even when I resize columns. I need something like "Datagrid.Columns(i).Left", but of course there is no such property. Is there a way to obtain such information?
 
Take the left position of the grid, and add to it the widths of all the visible columns until you arrive at the column you want :D
 
Hello, I have a datagrid in my project and I want to place label controls above each of its columns and those labels should stay above each column even when I resize columns. I need something like "Datagrid.Columns(i).Left", but of course there is no such property. Is there a way to obtain such information?

These things are called "Column Headers" and are a part of the DataGridView by default, though they can be hidden.

Example:
Here is a datagridview. It has labels above the columns that move and resize with the columns. The labels are ID, Name and Birthday:

datagridview-to-excel-1.gif
 
Hi guys, I found it at last. I can get the column bounds using:

DataGridView.GetColumnDisplayRectangle(ColumnIndex, CutOverflow)

This function returns the bounding rectangle for a column specified by index.
 
Back
Top