GGC Combobox text alignment
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?
Example:
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".
Regards,
Johan
Example:
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".
Regards,
Johan
SIGN IN To post a reply.
6 Replies
HA
haneefm
Syncfusion Team
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,
Haneef
Please try this code and let me know if this helps.
this.grid.TableDescriptor.Columns["ComboBoxColumnName"].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Right;
Best regards,
Haneef
JO
Johan
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.
Regards,
Johan
I have also tried to change the HorizontalAlignment in the QueryCellStyleInfo-event, but that does not help either.
Regards,
Johan
HA
haneefm
Syncfusion Team
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,
Haneef
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,
Haneef
JO
Johan
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,
Johan
GridComboTextAlignment.zip
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,
Johan
GridComboTextAlignment.zip
J.
J.Nagarajan
Syncfusion Team
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);
Regards,
Nagaraj
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);
Regards,
Nagaraj
JO
Johan
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,
Johan
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,
Johan
SIGN IN To post a reply.
- 6 Replies
- 3 Participants
-
JO Johan
- Dec 3, 2007 03:49 PM UTC
- Dec 11, 2007 09:44 AM UTC