插入,更新和在WPF DataGrid中删除 [英] Insert, Update & Delete in WPF DataGrid
本文介绍了插入,更新和在WPF DataGrid中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello Team,
我在WPF表单上有数据网格,我想执行Insert,Update&删除。
我有代码在Windows窗体中为我做同样的事情但在WPF中也要这样做..
请帮助...
Hello Team,
I have datagrid on WPF form and I would like to perform Insert, Update & Delete.
I have code which do the same for me in Windows Forms but Want to the same in WPF..
Please help...
OleDbConnection Con_Admin = new OleDbConnection();
BindingSource bs = new BindingSource();
OleDbDataAdapter da;
DataTable dt;
public void Show_Admin_GridView()
{
try
{
Con_Admin.Open();
}
catch { }
dataGridView1.DataSource = null;
da = new OleDbDataAdapter(frm2_HomePage.frm8_Admin_GridQry, Con_Admin);
OleDbCommandBuilder MyCommandBuilder = null;
MyCommandBuilder = new OleDbCommandBuilder(da);
dt = new DataTable();
da.Fill(dt);
bs.DataSource = dt;
dataGridView1.DataSource = bs;
dataGridView1.Enabled = true;
dataGridView1.AutoResizeColumns();
try
{
Con_Admin.Close();
}
catch { }
}
public void SaveChanges()
{
try
{
da.Update(dt);
}
catch (Exception exceptionObj)
{
MessageBox.Show(exceptionObj.Message.ToString());
}
}
推荐答案
你甚至搜索谷歌?
请按照以下文章进行操作:
WPF DataGrid控件 - 在数据库中插入新行 [ ^ ]
WPF DataGrid控件 - 执行更新和删除操作 [ ^ ]
< a href =http://gsselle.wordpress.com/2013/05/26/wpf-datagrid-update-insert-and-delete-operations/> WPF数据网格更新,插入和删除操作 [< a href =http://gsselle.wordpress.com/2013/05/26/wpf-datagrid-update-insert-and-delete-operations/\"target =_ blanktitle =New Window> ^ ]
用于插入,更新和删除记录的WPF GridView示例 [ ^ ]
使用LINQ to SQL类在WPF DataGrid中显示/删除/编辑数据 [ ^ ]
Do you even search in Google?
Follow these articles to do that:
WPF DataGrid Control – Insert New Rows in Database[^]
WPF DataGrid Control - Performing Update and Delete Operations[^]
WPF Datagrid Update, Insert and Delete Operations[^]
WPF GridView Sample To Insert, Update, and Delete Records[^]
Show/Delete/Edit data in WPF DataGrid using LINQ to SQL Classes[^]
这篇关于插入,更新和在WPF DataGrid中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文