Getting image from image list to display right justified with text

I have no problems getting my icon in a cell with some text, but it shows like this:

ICON Some text in the cell |

I would like:

Some text in the cell ICON |

I am adding an imagelist to the cell referencing the appropriate Image, and it is a Static cell type, but I cant find an align method or property.

Is this possible? Thanks in advance.

1 Reply

JJ Jisha Joy Syncfusion Team March 22, 2010 12:23 PM UTC

Hi George,

Thank you for your interest in Syncfusion products.

You could achieve the desired behavior by handling DrawCellDisplayText event of GridControl. See the code:

Private Sub gridControl1_DrawCellDisplayText(ByVal sender As Object, ByVal e As GridDrawCellDisplayTextEventArgs)
If e.RowIndex > 0 AndAlso e.ColIndex =2 Then
Dim rect As Rectangle = e.TextRectangle
Dim g As Graphics = Me.gridControl1.CreateGridGraphics()
GridStaticCellRenderer.DrawText(e.Graphics, e.Style.Text, e.Style.GdipFont, rect, e.Style, e.Style.TextColor, False)
Dim width As Integer = System.Convert.ToInt32((g.MeasureString(e.Style.Text, Me.Font).Width))
rect.Width = width
rect.X = rect.X + width
GridStaticCellRenderer.DrawImage(e.Graphics, Me.imageList1, 0, rect, False)
e.Cancel = True

End If
End Sub


Sample for your reference:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GCTextImage-1661520062.zip

Please let me know if this helps.

Regards,
Jisha

Loader.
Up arrow icon