DataGrid RowHeader Text

jshurpin

Member
Joined
Dec 15, 2005
Messages
8
Programming Experience
10+
Hi.

Is it possible to place text in the row headers of a datagrid? I don't see a property that will do this, but "there has to be a way".

Thanks,
Joe
 
I'm not a great user of the DataGrid so I've never done it myself, but I believe that you need to use DataGridColumnStyles. Follow the Windows Forms FAQ link in my signature and then check out the DataGrid section, which has heaps of information on using the DataGrid.
 
Thank you, your "Windows Forms FAQ" has a way (using Paint). But it seems an awfully elaborate way to do something so simple. Does anyone know if this has been changed in VS.Net 2005 ?
 
It has and it hasn't. The DataGrid hasn't changed but .NET 2.0 also includes the DataGridView. It works in quite a different way to the DataGrid with many things just like you want to do being much easier. The only real drawback that I can see, and it is a big one if you want to do this, is that there doesn't seem to be a way to show parent-child relationships between tables in the one grid.
 
DataGridView RowHeader

:confused: I have the same problem. I want to write text in the header of the row in datagridview. This property exists in the column header "DataGridView.Col(colIndex).cellText".
Could anyone help me,please?.
 
I dont know if this is even needed any more but here is an example. It is used with a DataGridView though and not with a DataGrid (which are much less flexible).

Me.DataGridView1.Rows.Item(Index).HeaderCell.Value = "Row Header Text"

It works for me so it should work for you. Unless you really want to work with a DataGrid for personal reasons, you should convert to a DataGridView.
 
DataGridView

Hii UncleRonin ,

Thank u for your replay, i am really use DataGridView not datagrid but there is a problem in this solution that i cant make allignment to the text that i write on the row header

Thanks
 
Yo

me.DataGridView1.Rows.Item(0).HeaderCell.Style.Alignment =DataGridViewContentAlignment.MiddleCenter

Try that. It should work but I havnt tried it myself
 
Thanks

Thanks very much for your replay about the header text allignmen.
Logically this line

me.DataGridView1.Rows.Item(0).HeaderCell.Style.Alignment
=DataGridViewContentAlignment.MiddleCenter

must work, but i dont know why it doesn't wok.

thanks
 
Me.DGV.Rows.Item(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
Definitely works. Are you referencing the correct DataGridView in your code and are you referencing the right row? (please post some of your code so we can see what's up)

I know that with aligning headers by the center that they do have an offset to the left and don't center correctly.
 
Back
Top