8 Answers, 1 is accepted
0
Hello GEB,
Kind regards,
Milan
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
You just have to create a simple GridViewCell style and set the HorizontalAlignment property to Right. For example:
<
telerik:GridViewDataColumn
Header
=
"Name"
DataMemberBinding
=
"{Binding Name}"
>
<
telerik:GridViewDataColumn.CellStyle
>
<
Style
TargetType
=
"gridView:GridViewCell"
>
<
Setter
Property
=
"HorizontalAlignment"
Value
=
"Right"
/>
</
Style
>
</
telerik:GridViewDataColumn.CellStyle
>
</
telerik:GridViewDataColumn
>
Kind regards,
Milan
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Kevin Happe
Top achievements
Rank 1
answered on 20 May 2010, 03:52 PM
Can you give an example of how I would center or right align a cell in c#? My columns are added dynamically.
0
Hi,
Here is an example:
RadGridView1.Columns.Add(new GridViewDataColumn() { DataMemberBinding = new Binding("CustomerID"), TextAlignment = TextAlignment.Right });
Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Here is an example:
RadGridView1.Columns.Add(new GridViewDataColumn() { DataMemberBinding = new Binding("CustomerID"), TextAlignment = TextAlignment.Right });
Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kevin Happe
Top achievements
Rank 1
answered on 20 May 2010, 04:01 PM
I should have given you some more information. I am having a problem with a checkbox column, by default it is left aligning and I want to be center aligned. I tried using textalignment and it didnt change anything.
0
Hello,
Here is another example:
var style = new Style(typeof(GridViewCell));
var setter = new Setter(GridViewCell.HorizontalContentAlignmentProperty, HorizontalAlignment.Right);
style.Setters.Add(setter);
RadGridView1.Columns.Add(new GridViewDataColumn()
{
DataMemberBinding = new Binding("CustomerID"),
CellStyle = style
});
If you prefer you can define the style as resource instead.
Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Here is another example:
var style = new Style(typeof(GridViewCell));
var setter = new Setter(GridViewCell.HorizontalContentAlignmentProperty, HorizontalAlignment.Right);
style.Setters.Add(setter);
RadGridView1.Columns.Add(new GridViewDataColumn()
{
DataMemberBinding = new Binding("CustomerID"),
CellStyle = style
});
If you prefer you can define the style as resource instead.
Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kevin Happe
Top achievements
Rank 1
answered on 20 May 2010, 04:16 PM
Awesome, That worked like a champ and gives me a good example of setting cell styles at runtime.
Thanks
Kevin Happe
Thanks
Kevin Happe
0
GEB
Top achievements
Rank 1
answered on 22 May 2010, 01:29 PM
Make certain that you set the HorizontalContentAlignment property, as opposed to HorizontalAlignment. Both will cause the text to be right-justified. However, double-click will not work properly if HorizontalAlignment is set instead of HorizontalContentAlignment. This is contrary to the response given on 2/9/2010.
0
Charles
Top achievements
Rank 2
answered on 01 Mar 2011, 10:16 PM
I had this same issue and attempted the solution given above. It didn't work. I received an error:
Failed to create a 'System.Type' from the text 'gridView:GridViewCell'. [Line: 80 Position: 47]
That is the position where the TargetType is defined.
Failed to create a 'System.Type' from the text 'gridView:GridViewCell'. [Line: 80 Position: 47]
That is the position where the TargetType is defined.