基本的に私は C# と WPF の初心者ですが、
私は DataTable とバインドする WPF DataGrid を持っています
ここに DataGrid の XAML
<DataGrid AutoGenerateColumns="True" CanUserAddRows="False" HorizontalAlignment="Left"
ItemsSource="{Binding Path=., Mode=TwoWay}"
Margin="10,99,0,56" Name="dataGrid1"
SelectionUnit="CellOrRowHeader" Width="1044">
</DataGrid>
ここでは、MySQL データを DataTable にロードする別のクラスの public メソッド
public DataTable dtQueries(string userQuery, string cnString = null)
{
//##Open the connection
if (cnString == null)
{
this.open_connection("localConnectionString");
}
else
{
this.open_connection(cnString);
}
//##Create Command
MySqlCommand cmd = new MySqlCommand(userQuery, mysqlConn);
//##Create a data reader and Execute the command
DataTable table = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(table);
return table;
}
ここでは、DataTable を DataGrid にバインドするコード
DataSet ds = new DataSet();
string qGetDM = "SELECT * FROM mytable";
dataGrid1.BeginInit();
ds.Tables.Add(dboperation.dtQueries(qGetDM, "clientLegacyDM"));
dataGrid1.DataContext = ds.Tables[0];
dataGrid1.Items.Refresh();
dataGrid1.EndInit();
DataGridでのユーザーの変更に基づいてMySQLデータベースを更新するためのSubmitButtonとして1つのコマンドボタンがあります..
誰もこれを行う方法を提案していますか?
thx、私は本当に助けてくれてありがとう:D