I have a radgrid with the cell text alignment, in the first column, set to middle left.
The text in the cell (and the headertext) is to close to the edge of the radgrid.
The text in the cell looks missplaced since the is a 5px margin both above and below the text, but to the left there is none.
Is it possible to add a spacing to the left of the text (both headertext and cell), that is equal to the spacing above and below the text?
Can it be done by using FormatString?
Regards
Per Bornsjo
4 Answers, 1 is accepted
The best option in this case is to set a left padding. This can be done when handling ViewCellFormatting to affect also the header cell. Consider the following sample:
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) |
{ |
e.CellElement.Padding = new Padding(5, 0, 0, 0); |
} |
I hope this helps. If you have further questions, I will be glad to answer them.
Best wishes,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thanks for your quick reply.
Just what I was looking for :)
Regards
Per Bornsjo
Hello, Martin,
Customizing the cell's look is possible at run time in the code. Since RadGridView uses UI virtualization it is suitable to use formatting events such as CellFormatting/ViewCellFormatting events. Additional information is available here: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells
Another approach is to modify directly the theme that you are using with Visual Style Builder tool. You can read more details about using the VSB and modifying themes here:
1. Loading predefined themes
2. Working with Repository Items
3. Saving and Loading Theme Files
4. Loading Themes from an External File
5. Loading Themes from a Resource
6. Applying Theme to a Control
7. https://www.telerik.com/videos/winforms/what-is-new-in-visual-style-builder-for-q1-2010
I hope this information is useful. Should you have other questions do not hesitate to ask.
Regards,
Nadya
Progress Telerik