我创建了一个表
DataTable table= new DataTable();
其中我逐行添加数据。但是在一行中,第一列是字符串,其他列是数字。 我想将第一列左对齐,数字右对齐。是否有任何方法可以在添加到行中时对齐单元格?
答案 0 :(得分:-1)
在
<Window.Resources>
编写以下代码:
<Style x:Key="RightCellStyle" TargetType="{x:Type telerik:GridViewCell}">
<Setter Property="HorizontalAlignment" Value="Right">
</Setter>
</Style>
<Style x:Key="LeftCellStyle" TargetType="{x:Type telerik:GridViewCell}">
<Setter Property="HorizontalAlignment" Value="Left">
</Setter>
</Style>
在
<telerik:RadGridView.Columns>
编写以下代码,即将样式设置为单元格
<telerik:GridViewDataColumn Header="Your header" CellStyle="{StaticResource LeftCellStyle }"></telerik:GridViewDataColumn>
和你要正确对齐的单元格一样;刚设置
CellStyle="{StaticResource RightCellStyle }"
告诉我你是否在寻找它?