c1datagrid标题居中、设置列宽
版主:c1datagrid后台绑定数据源后,如何设置列宽,列标题居中显示?
谢谢!
可以在xaml中这样设置
<c1:DataGridBoundColumn Binding="{Binding DataField}" Width="66">
<c1:DataGridBoundColumn.Header>
<TextBlock HorizontalAlignment="Center" Text=" adfsdfsdf"></TextBlock>
</c1:DataGridBoundColumn.Header>
</c1:DataGridBoundColumn>
xaml文件:<c1:C1DataGrid x:Name="C1DataGrid1" HorizontalAlignment="Left" Height="357" Margin="3,0,0,0" VerticalAlignment="Top" Width="789" CanUserAddRows="False" CanUserResizeColumns="False" CanUserRemoveRows="False" ColumnWidth="Auto*">
<c1:C1DataGrid.Columns>
<c1:DataGridBoundColumn Binding="{Binding DataField}" Width="66">
<c1:DataGridBoundColumn.Header>
<TextBlock HorizontalAlignment="Center" Text=" adfsdfsdf"></TextBlock>
</c1:DataGridBoundColumn.Header>
</c1:DataGridBoundColumn>
</c1:C1DataGrid.Columns>
</c1:C1DataGrid>
c#文件绑定DefaultView
SqlStr = "Select * From Order By ";
Da = new SqlDataAdapter(SqlStr, DataClass.SqlConn.MySqlCon);
Ds = new DataSet();
Da.Fill(Ds, "Device");
if (Ds.Tables.Rows.Count > 0)
{
C1DataGrid1.ItemsSource = Ds.Tables.DefaultView;
C1DataGrid1.ColumnHeaderHeight = 40;
C1DataGrid1.SelectedIndex = 3;//选择第3行
}
运行:
没有居中达到效果
那你上传一个demo上来看一下吧。
另外C1DataView目前已经停止更新了,建议可以使用后面的替代控件flexgrid设置这些内容会更方便
页:
[1]