SQL サーバーから WPF Datagrid にデータをバインドしようとしていますが、残念ながら一部の列は正しくバインドされていません。データバインディング用のこのコードがあります..
SqlConnection cn;
SqlDataAdapter da;
DataSet ds;
public Window1()
{
InitializeComponent();
cn = new SqlConnection ("Connection String");
cn.Open();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
da = new SqlDataAdapter("Select * from table_1",cn);
ds = new DataSet();
da.Fill(ds);
dataGrid1.ItemsSource = ds.Tables[0].DefaultView;
}
助けて Pllllllllllllzzzzzzzz
ここにXMLがあります
<Window
x:Class="Smart.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Smart"
Loaded="Window_Loaded"
Height="779"
Width="1180">
<Grid>
<Grid.ColumnDefinitions></Grid.ColumnDefinitions>
<DataGrid
AutoGenerateColumns="True"
Name="dataGrid1"
IsReadOnly="True"
Height="870"
Width="1063"
Margin="104.5,85,0,0"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Grid.Row="0"
Grid.Column="0"
FontSize="15" />
....
そして、これが私のフォームのデータグリッドの画像プレビューです
これで、列 3、6、および 7 を除くすべての列に結果が正しく表示されていることがわかります。