i used a rad grid view in win form app.i changed text alignment to center in normal mode with cell formatting.but when i clicked on cell to edit that ,alignment is left.how can change that to center to?
You can access the editors in the CellEditorInitialized event and change the TextAlignment property to HorizontalAlignment.Center. In order to achieve your goal, please have a look at the following code snippet:
RadTextBoxEditor textEditor = e.ActiveEditor as RadTextBoxEditor;
GridSpinEditor spinEditor = e.ActiveEditor as GridSpinEditor;
if (spinEditor != null)
{
GridSpinEditorElement el = spinEditor.EditorElement as GridSpinEditorElement;
el.TextAlignment = HorizontalAlignment.Center;
}
if (textEditor != null)
{
RadTextBoxEditorElement el = textEditor.EditorElement as RadTextBoxEditorElement;
el.TextAlign = HorizontalAlignment.Center;
}
}
The example demonstrates how to set the alignment of two editors (textbox editor and spin editor). If you use another editor in you application, you need to set their alignment too.
I also attached a sample demo.
Should you have further questions, I would be glad to help.
Regards,
Ralitsa
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.