首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#winform 用DataTable把列加进Datagridview

2012-12-21 
C#.winform 用DataTable把列添进Datagridview用DataTable把列添进DataGridview 放在Load 事件里面DataTabl

C#.winform 用DataTable把列添进Datagridview

用DataTable把列添进DataGridview 放在Load 事件里面

DataTable dtVoucher = new DataTable();dtVoucher.Columns.Add("acCode", typeof(string));            dtVoucher.Columns.Add("acName", typeof(string));            dtVoucher.Columns.Add("particulars", typeof(string));            dtVoucher.Columns.Add("debit", typeof(string));            dtVoucher.Columns.Add("credit", typeof(string));            DataRow dr_one = dtVoucher.NewRow();            dr_one["acCode"] = "";            dr_one["acName"] = "";            dr_one["particulars"] = "";            dr_one["debit"] = "";            dr_one["credit"] = "";            dtVoucher.Rows.Add(dr_one);            DataRow dr_two = dtVoucher.NewRow();            dr_two["acCode"] = "";            dr_two["acName"] = "";            dr_two["particulars"] = "";            dr_two["debit"] = "";            dr_two["credit"] = "";            dtVoucher.Rows.Add(dr_two);            dataGridView1.DataSource = dtVoucher;

?

热点排行