Results 1 to 3 of 3

Thread: set RightToLeft=True only for one Column of a Datagridview

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2012
    Posts
    72

    set RightToLeft=True only for one Column of a Datagridview

    hi

    i want to set RightToLeft=true for only one column of a datagridview.how can i do this?

  2. #2

    Re: set RightToLeft=True only for one Column of a Datagridview

    Per MSDN documentation, the Control object (which is what the DataGridView inherits) is what is set as RightToLeft. There is no property or method to set a DataGridViewColumn RightToLeft because it is not a Control. You must set the entire control (aka, the DataGridView itself) to be RightToLeft.
    Last edited by formlesstree4; May 8th, 2013 at 11:37 AM. Reason: Clarification

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2012
    Posts
    72

    Re: set RightToLeft=True only for one Column of a Datagridview

    Quote Originally Posted by formlesstree4 View Post
    Per MSDN documentation, the Control object (which is what the DataGridView inherits) is what is set as RightToLeft. There is no property or method to set a DataGridViewColumn RightToLeft because it is not a Control. You must set the entire control (aka, the DataGridView itself) to be RightToLeft.
    thanks ... but i found a way with Cell_Painting event in c#... i used it and it is ok :
    Code:
    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;
           }
       }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width