This is a migrated thread and some comments may be shown as answers.
Cell spacing?
4 Answers 125 Views
This is a migrated thread and some comments may be shown as answers.
Per
Top achievements
Rank 1
Per asked on 27 May 2009, 07:53 AM
Hi

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

Sort by
0
Accepted
Jack
Telerik team
answered on 27 May 2009, 08:17 AM
Hi Per,

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.
0
Per
Top achievements
Rank 1
answered on 27 May 2009, 08:49 AM
Hi!

Thanks for your quick reply.

Just what I was looking for :)

Regards
Per Bornsjo
0
Martin
Top achievements
Rank 1
Veteran
answered on 05 Aug 2020, 02:06 PM
Is it possible to do this directly from the view and not use any code-behind?
0
Nadya
Telerik team
answered on 05 Aug 2020, 04:08 PM

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

Asked by
Per
Top achievements
Rank 1
Answers by
Jack
Telerik team
Per
Top achievements
Rank 1
Martin
Top achievements
Rank 1
Veteran
Nadya
Telerik team
Share this question
or