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>
<c1ataGridBoundColumn Binding="{Binding DataField}" Width="66">
<c1ataGridBoundColumn.Header>
<TextBlock HorizontalAlignment="Center" Text=" adfsdfsdf"></TextBlock>
</c1ataGridBoundColumn.Header>
</c1ataGridBoundColumn>
</c1:C1DataGrid.Columns>
</c1:C1DataGrid>
c#文件绑定DefaultView
SqlStr = "Select * From [Device] Order By [DeviceID]";
Da = new SqlDataAdapter(SqlStr, DataClass.SqlConn.MySqlCon);
Ds = new DataSet();
Da.Fill(Ds, "Device");
if (Ds.Tables[0].Rows.Count > 0)
{
C1DataGrid1.ItemsSource = Ds.Tables[0].DefaultView;
C1DataGrid1.ColumnHeaderHeight = 40;
C1DataGrid1.SelectedIndex = 3;//选择第3行
}
运行:
没有居中达到效果
|