Hello,
Hopefully someone can help me out.
I want to have rownumbers in my datagridView rowheader. I searched the internet already. A lot of people talk about handling the paint event but I can't find a good example in Visual C++ .
Can somebody help me out with a good example or where I can find an example how to do it. I am working with DataGridView1 in my program.
Thanks,
Rodger

inserting rownumbers in the Rowheader
ismar
private: System::Void dataGridView1_CellPainting(System::Object^ sender, System::Windows::Forms::DataGridViewCellPaintingEventArgs^ e)
{
if((e->ColumnIndex==-1) && (e->RowIndex!=-1))
{
StringFormat^ sf = gcnew StringFormat();
sf->Alignment = StringAlignment::Center;
sf->LineAlignment = StringAlignment::Center;
e->PaintBackground(e->CellBounds, true);
int Row = e->RowIndex + 1;
String^ s = Row.ToString();
e->Graphics->DrawString(s,this->Font, Brushes::Black, e->CellBounds, sf);
e->Handled=true;
}
}
asalcedo
Thank you Ken Tucker, it works..
For people who want's the same; you have to add the following line in you source code next to the above void:
this
->dataGridView1->CellPainting += gcnew System::Windows::Forms::DataGridViewCellPaintingEventHandler(this,&Form1::dataGridView1_CellPainting);