How can I place text in the rowheader column of my DataGridView in C#

S

saravanan_article

Hi Team,

This is saravanan i am new to C#.. I am using VS2005 for my windows
based application.. I am using DataGridView to show the values.. What i
want is i want to display the text in the rowheaders of the
DataGridview and I want to enable the tooltip in the cells.

Thanks in advance

Any help or suggesstion is appreciated
 
S

scott blood

Hello,

I dont think your suppose to be able to change the RowHeader text in a
windows form, its quite simple in asp.net but in a windows form it can be a
pain in the behind.

However you could trying the following code.

private void MyDataGridView_RowPostPaint(object sender,
DataGridViewRowPostPaintEventArgs e)
{
// The using statement automatically disposes the brush.
using (SolidBrush b = new
SolidBrush(MyDataGridView.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString(e.RowIndex.ToString(),
e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 20,
e.RowBounds.Location.Y + 4);
}
}

Hope this helps in some way
Regards
Scott Blood
C# Developer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top