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.

Left align combobox display member in GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

127873 Dec 14,2016 03:55 PM Dec 19,2016 11:34 PM Windows Forms 5
loading
Tags: GridGroupingControl
Patrick Luijpers
Asked On December 14, 2016 03:55 PM

I found the following code to left align the display member of a data bound combobox on the GridGroupingControl.
this.grid.TableDescriptor.Appearance.AnyRecordFieldCell. HorizontalAlignment = GridHorizontalAlignment.Left;

However this aligns any record to the left, and overwriting the alignment to right for a numeric data field has no effect on the amount grid column.
gcAmount.Appearance.AnyRecordFieldCell.Format = "#,###.##";
gcAmount.Appearance.AnyRecordFieldCell.TextAlign = GridTextAlign.Right;


The data bound GridGroupingControl contains a column PayeeId, this column is represented as a combobox bound to the Payee dataset using DisplayMember and ValueMember.
The alignment is correct on the dropdown list of the combobox.

What is the proper way of aligning the display member in combobox on the GridGroupingControl on the left and the amount column to the right?


Neelakandan Kannan [Syncfusion]
Replied On December 15, 2016 08:01 AM

Hi Patrick , 
Thanks for using Syncfusion products. 

Query: 
What is the proper way of aligning the display member in combobox on the GridGroupingControl on the left and the amount column to the right? 
 
 
Solution 1: 
We do not have the direct support to right align the drop down list of the combox. But you can achieve your scenario by using the TableModel. EnableGridListControlInComboBox, TableModel.EnableLegacyStyle property and handling the QueryCellInfo event for GridListControl. Please refer the below code snippet and refer the attached sample, 
 
Code snippet: 
this.gridGroupingControl1.TableModel.EnableGridListControlInComboBox = true; 
this.gridGroupingControl1.TableModel.EnableLegacyStyle = false; 
 
GridDropDownGridListControlCellRenderer ren= (this.gridGroupingControl1.TableControl.CellRenderers["ComboBox"] as GridDropDownGridListControlCellRenderer) ; 
control = (ren.ListControlPart as GridListControl); 
control.Grid.QueryCellInfo += Grid_QueryCellInfo; 
void Grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) 
{ 
    e.Style.HorizontalAlignment = GridHorizontalAlignment.Right; 
    e.Style.Format = "#,###.##";     
} 
 
 
Solution 2: 
You can achieve your scenario by using the GridListControl instead of ComboBox CellType. Please refer the below code snippet, 
 
Code snippet: 
this.gridGroupingControl1.TableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.GridListControl; 
GridDropDownGridListControlCellRenderer ren= (this.gridGroupingControl1.TableControl.CellRenderers["GridListControl"] as GridDropDownGridListControlCellRenderer) ; 
control = (ren.ListControlPart as GridListControl); 
control.Grid.QueryCellInfo += Grid_QueryCellInfo; 
 

Sample link: GridGroupingControl 

Reagards, 
Mohanraj G 


Patrick Luijpers
Replied On December 15, 2016 10:14 AM

Thank you Mohanraj for the example.

It is not working for me. I am trying to left align the text in the combobox (Payee) and right align invoice amount (see attached image).
Unable to successfully adapt your solutions to override the Payee combobox and align left.

Thanks,
Patrick

Attachment: Sample_Grid_Layout_17119381.zip

Mohanraj Gunasekaran [Syncfusion]
Replied On December 16, 2016 06:06 AM

Hi Patrick, 
 
Sorry for the inconvenience caused, 
 
By default, numeric column HorizontalAlignment is right and other column HorizontalAlignment is left. If you set the HorizontalAlignment as left using TableDescriptor.Appearance .AnyRecordFieldCell property. You should set the Right alignment for numeric column(Amount) using HorizontalAlignment property. Also, use the TextAlign property to align the RecordFieldCells. Please refer the below code snippet and refer the attached sample, 
 
Code snippet: 
this.gridGroupingControl1.TableDescriptor.Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Left; 
this.gridGroupingControl1.TableDescriptor.Columns["Amount"].Appearance.AnyRecordFieldCell.HorizontalAlignment = GridHorizontalAlignment.Right; 
 
(or) 
 
this.gridGroupingControl1.TableDescriptor.Appearance.AnyRecordFieldCell.TextAlign =  GridTextAlign.Left; 
this.gridGroupingControl1.TableDescriptor.Columns["Amount"].Appearance.AnyRecordFieldCell.TextAlign = GridTextAlign.Right; 
 
 
 
 
Sample link:  GridGroupingcontrol 
 
Regards, 
Mohanraj G 
 


Gangabharathy Murugasen [Syncfusion]
Replied On December 19, 2016 12:25 AM

From: Patrick Luijpers [mailto:patrick@luijpers.com]
Sent: Friday, December 16, 2016 9:10 AM
To: Syncfusion Support <support@syncfusion.com>
Subject: Re: Syncfusion support community forum 127873, Left align combobox display member in GridGroupingControl, has been updated.
 

Thank you for this solution, simple and effective. 
 
  


Mohanraj Gunasekaran [Syncfusion]
Replied On December 19, 2016 11:34 PM

Hi Patrick,  
 
Thanks for your update. 
 
We are glad to know that your reported problem has resolved. Please Let us know if you need any further assistance.  
 
Regards, 
Mohanraj G. 


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.

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.

;