Take the 2-minute tour ×

How do I set the RightToLeft property for a particular DataGridViewCell in a DataGridViewColumn?

share|improve this question
I need to set Direction not Alignment for cell –  mbmsit Feb 17 '11 at 9:50
What does that mean? I'm not sure that I understand the distinction. As my answer explains, you cannot set the RightToLeft property for individual cells; it only applies to the entire control. It's designed for locales using right-to-left fonts, in which case everything on the screen would need to be right-to-left, not just one particular cell. How is "direction" different than "alignment"? –  Cody Gray Feb 19 '11 at 4:35
(I know this is old) The use of right-to-left fonts doesn't necessary mean that everything on the screen would needs to be right-to-left. For example you could have a DataGridView that is displaying translations of words in different langs. The column showing a RTL lang should be displayed RTL. It seems that when using a .net DataGridView to achieve this one has to set the cell font to a RTL and set CellStyle.Alignment to DataGridViewContentAlignment.MiddleRight. (although this doesn't seem to work using mono winforms) –  Tom Sep 17 '12 at 17:04

4 Answers 4

Such a property does not exist. You need to set the RightToLeft property of the entire control.

I suspect that you're attempting to mis-use the property to right-justify your text. It's intended to enable support for locales that use right-to-left fonts, not for custom formatting.

If altering formatting is your goal, each DataGridViewCell has a Style property that accepts an instance of the DataGridViewCellStyle class. You can set its Alignment property to "MiddleRight" to align the content of the cell vertically at the middle and horizontally at the right. For more information, see: How to: Format Data in the Windows Forms DataGridView Control.

share|improve this answer

To do so for the whole column, use

dataGridView.Columns["column name"].DefaultCellStyle.Alignment = DataGridViewAlignment.MiddleRight;

Although I believe the individual cell's style will override this.

share|improve this answer

I know it's an old question, but as others said, DataGridViewCell and DataGridViewColumn don't have the RightToLeft property. However, there are workarounds to this problem:

  1. Handle the CellPainting event and use the TextFormatFlags.RightToLeft flag:

    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;

    (Code taken from CodeProject question.)

  2. If it's only one particular cell in the DGV, you may try to insert the invisible RTL character (U+200F) in the beginning of the cell content.

share|improve this answer

As simple as that:

DataGridView1.Columns["name of column"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
share|improve this answer

Your Answer


