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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GGC Combobox text alignment

Thread ID:





70231 Dec 3,2007 03:49 PM UTC Dec 11,2007 09:44 AM UTC WinForms 6
Tags: GridControl
Asked On December 3, 2007 03:49 PM UTC

I have a combobox in a grid grouping control which is databound to a DataTable. Is it possible to align the text of the combobox so that the rightmost part of the text is shown if the combobox width is smaller than the text width?

The selected text is "Microsoft Excel". The width of the combobox (when not dropped) allows only 7 characters visible. The visible text should then be "t Excel".


haneefm [Syncfusion]
Replied On December 3, 2007 05:31 PM UTC

Hi Johan,

Please try this code and let me know if this helps.

this.grid.TableDescriptor.Columns["ComboBoxColumnName"].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Right;

Best regards,

Replied On December 4, 2007 10:00 AM UTC

No, the visible text is still "Microso". If I change "AnyRecordFieldCell" to "AnyCell", the column header is aligned to the right, but not the combobox text.

I have also tried to change the HorizontalAlignment in the QueryCellStyleInfo-event, but that does not help either.


haneefm [Syncfusion]
Replied On December 4, 2007 03:34 PM UTC

Hi John,

Thank you for your update.

I have tested the attached sample to reproduce this issue, but could not get this. Maybe I am not following the steps that you are doing. Is it possible for you to upload us a minimal sample to reproduce the issue here? This will help us to analyse the issue further.

Sample : GridComboBoxTextAlignMent.zip

Best regards,

Replied On December 5, 2007 09:13 AM UTC

Hi Haneef,

Thank you for your sample. The text is right aligned. And on closer inspection, it is right aligned in my application as well. However, my problem remains. The text in my gridcombobox is wider than the column width which means that only the first part of the text is visible. What I would like is to have the last part of the text visible instead since it contains the most important information if the first part is the same.

In the enclosed example I have made the text longer in the first column so that only a part of it is visible. Unless the combo is dropped (or the column width is changed), it looks as if all rows have the same value selected. I would like to have the text "scrolled" so that the last part of the text (containing the number) is visible.

Best regards,


J.Nagarajan [Syncfusion]
Replied On December 11, 2007 01:07 AM UTC

Hi Johan,

You could resolve this problem by calling ResizeToFit on the colwidths which helps in showing all the text in the combobox cells. Please add the below code to your form load.

int field = this.gridGroupingControl1.TableDescriptor.NameToField("Col1");
int index = this.gridGroupingControl1.TableDescriptor.FieldToColIndex(field);
this.gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Col(index), GridResizeToFitOptions.NoShrinkSize);


Replied On December 11, 2007 09:44 AM UTC

Hi Nagaraj

Thank you for your reply. Unfortunately we cannot make the column wider.

I have managed to find a solution to the problem:

In the TableControlDrawCellDisplayText event

Graphics g = e.Inner.Graphics;

string newDisplayString = e.Inner.DisplayText;

while(g.MeasureString(newDisplayString, new Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))).Width > e.Inner.ClipBounds.Width)

newDisplayString = newDisplayString.Substring(1);

e.Inner.DisplayText = newDisplayString;

Best regards,


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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