Ticket T357158
Visible to All Users

Setting right-to-left mode for a single grid cell

created 9 years ago

I'm displaying multiple translations of different languages (some of them being right-to-left languages) in a single grid. So I need to set right-to-left mode for a single grid cell but not for the whole grid.

I tried to use this code to achieve this behavior:

C#
private void Grid_RowCellStyle(object sender, RowCellStyleEventArgs e) { if (translationColumns.Contains(e.Column)) { var row = grid.GetRow(e.RowHandle) as TranslatableEntity; if (row?.Locale != null) { e.Appearance.TextOptions.RightToLeft = row.Locale.GetCultureInfo().TextInfo.IsRightToLeft; } } }

This sets Appearance.TextOptions.RightToLeft for all cells that contain right-to-left content but the setting has no effect at all.

Additionally setting "RightToLeft=true" on the whole grid does not affect the behavior of tooltips. They are still in left-to-right mode.

Answers approved by DevExpress Support

created 9 years ago

Hi Matthias,

The capability of setting the Right To Left layout for a particular column or cell is not supported.

As a possible solution, you can draw a text in the Right To Left layout manually by using standard methods of the Graphics class. Take a look, for example, at the .net - Printing Right-To-Left in c# - Stack Overflow article, where the issue with drawing text in the RTL mode is discussed.

Let me know if you have additional questions.

    Comments (1)

      dear expert

      this code for single column RTL

      Shared Sub CustomDrawCell(ByVal gridControl As GridControl, ByVal gridView As GridView)
      ' Handle this event to paint cells manually
      AddHandler gridView.CustomDrawCell,
      Sub(s, e)
      If e.Column.VisibleIndex <> 4 Then
      Return
      End If

      Dim drawFormat As StringFormat = New StringFormat()
      drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft
      e.Appearance.DrawString(e.Cache, e.DisplayText, e.Bounds, drawFormat)
      e.Handled = True

      End Sub
      End Sub

      Thanks Alisher your support link is useful for me.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.