Hi all,
How can I change the RightToLeft property for the column of a DataGridView and not the whole DataGridView.
i.e
I want my DataGridView to contain two columns, one RightToLef and the other one LeftToRight.
Solution found:
Handle the DataGridView.CellPainting event and add the following code, which simply draws the cell and align it to the right and rtl flags.
private void RTLColumnsDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == RTLColumnID && e.RowIndex >= 0)
{
e.PaintBackground(e.CellBounds, true);
TextRenderer.DrawText(e.Graphics, e.FormattedValue.ToString(),
e.CellStyle.Font, e.CellBounds, e.CellStyle.ForeColor,
TextFormatFlags.RightToLeft | TextFormatFlags.Right);
e.Handled = true;
}
}
Thanks,
Gabi.