GridView has a default text alignment for new columns as 'MiddleCenter'.
Default alignment for new GridViewDataRowInfo is 'left'.
Please can these be the same ?
Hi Ian,
The feedback item status is changed to Declined due to inactivity in this thread.
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
The default text alignment in RadGridView's columns is different for the different column types. For example, GridViewDecimalColumn has ContentAlignment.MiddleRight and GridViewTextBoxColumn is left aligned.
However, each column offers TextAlignment property allowing you to control how the text to be aligned:
GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn("Id");
decimalColumn.TextAlignment = ContentAlignment.MiddleCenter;
this.radGridView1.Columns.Add(decimalColumn);
GridViewTextBoxColumn textColumn = new GridViewTextBoxColumn("Name");
textColumn.TextAlignment = ContentAlignment.MiddleCenter;
this.radGridView1.Columns.Add(textColumn);
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
for (int i = 0; i < 10; i++)
{
this.radGridView1.Rows.Add(i, "Row" + i);
}
For the new row, the column's TextAlignment is also considered:
As to the editor which is activated, indeed, it is always left aligned which is expected. If you need to manage the editor's text alignment, it is necessary to do it in the CellEditorInitialized event:
private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
RadTextBoxEditor textEditor = e.ActiveEditor as RadTextBoxEditor;
GridSpinEditor spinEditor = e.ActiveEditor as GridSpinEditor;
if (textEditor!=null)
{
RadTextBoxEditorElement el = textEditor.EditorElement as RadTextBoxEditorElement;
el.TextAlign = HorizontalAlignment.Center;
}
else if (spinEditor!=null)
{
RadSpinEditorElement el = spinEditor.EditorElement as RadSpinEditorElement;
el.TextAlignment = HorizontalAlignment.Center;
}
}
Please give it a try and see how it works for your scenario.
I have updated this request's status to "Need More Info" as it is not quite clear to me what is the exact requirement that you are trying to acomplish. Could you please elaborate?
Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.