BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hello,
I have a ButtonColumn with multiple buttons. I not find the proper CellButton property to align the text center (horizontal).
I follow this example: https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.GridButtonColumn.html#%22%22
Can you help me please align the text center?
Thank you!
BR, SZL
Hi SZL,
To center the text in a button column, you can use the column cell style. You should set the HorizontalAlignment property to 'Center' and then bind this cell style to the button column. This will ensure that the text in the button is centered. Refer to the below code snippets to get more information.
List<CellButton> buttons = new List<CellButton>(); buttons.Add(new CellButton() { Text = "B", AutoSize = false}); buttons.Add(new CellButton() { Text = "M", AutoSize = false }); buttons.Add(new CellButton() { Text = "T", AutoSize = false }); buttons.Add(new CellButton() { Text = "C", AutoSize = false }); buttons.Add(new CellButton() { Text = "L", AutoSize = false });
CellStyleInfo cellStyleInfo = new CellStyleInfo(); cellStyleInfo.HorizontalAlignment = HorizontalAlignment.Center; this.sfDataGrid1.Columns.Add(new GridButtonColumn() { Buttons = buttons, CellStyle = cellStyleInfo
}); |
Regards,
Sathiyathanam
Hi,
Thank you very much, its working well!
BR, SZL
SZL,
We are glad that the provided response meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out.