I found the solution myself.
You have to override the callpainting event and modify CellBounds.Top -= 1;
void dataGridView_CellPainting(
{
try
{
Rectangle CellBounds = e.CellBounds;
CellBounds.Location = new Point(CellBounds.Left, CellBounds.Top - 1);
if (e.ColumnIndex > -1 && e.RowIndex > -1 && e.RowIndex != moListCtrl.NewRowIndex)
{
StringFormat sf = new StringFormat();
if (moListCtrl.Columns[e.Colu
{
sf.Alignment = StringAlignment.Far;
}
e.Paint(e.CellBounds, DataGridViewPaintParts.All
if (this.moListCtrl[e.ColumnI
{
using (SolidBrush sb = new SolidBrush(e.CellStyle.Sel
{
e.Graphics.DrawString(e.Va
}
}
else //unselected
{
using (SolidBrush sb = new SolidBrush(e.CellStyle.For
{
e.Graphics.DrawString(e.Va
}
}
e.Handled = true;
}
}
catch (Exception) { }
}
Main Topics
Browse All Topics





by: strickddPosted on 2009-05-28 at 11:32:01ID: 24496391
you can apply a style to the "td" tag in a CSS or you can loop through all the rows after they are created and apply a style to text-align:right.