We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Getting image from image list to display right justified with text

Thread ID:

Created:

Updated:

Platform:

Replies:

93563 Mar 19,2010 07:46 PM UTC Mar 22,2010 12:23 PM UTC Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 19, 2010 07:46 PM UTC

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.

Jisha Joy [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;