欢迎投稿

今日深度:

WPF中DataGrid利用DataTable绑定sqlite的查询结果,wpfsqlite

WPF中DataGrid利用DataTable绑定sqlite的查询结果,wpfsqlite


之前开发WINForm程序时,使用BindingSource来绑定查询的结果,如下:

 BindingSource Bs = new BindingSource();
 SQLiteDataReader sr = rfidDB.querytable("register");
if (sr != null )
    {
        Bs.DataSource = sr;
        dataGridView1.DataSource = Bs;
    }

但在WPF中,没有BindingSource这个类,因为它属于Form,因此应该借助DataTable来绑定数据,如下:

SQLiteDataReader sr = rfidDB.querytable("register");
if (sr != null)
{
    DataTable Dt = new DataTable();
    Dt.Load(sr);
    dataGridView1.ItemsSource = Dt.DefaultView;
}

 

www.htsjk.Com true http://www.htsjk.com/SQLite/30754.html NewsArticle WPF中DataGrid利用DataTable绑定sqlite的查询结果,wpfsqlite 之前开发WINForm程序时,使用BindingSource来绑定查询的结果,如下: BindingSource Bs = new BindingSource(); SQLiteDataReader sr = rfidDB.querytable("reg...
相关文章
    暂无相关文章
评论暂时关闭