码迷,mamicode.com
首页 > 其他好文 > 详细

c# 用代码定义带数据的datatable

时间:2014-08-07 12:29:29      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   数据   ar   div   代码   new   

            DataTable customerTable = new DataTable();
            customerTable.Columns.Add("clsCustomerID", typeof(string));
            customerTable.Columns.Add("clsCustomerNM", typeof(string));      //定义列

            DataRow row = customerTable.NewRow();     //新加一行
            row["clsCustomerID"] = "01.2136";
            row["clsCustomerNM"] = "MAXIS1";

            customerTable.Rows.Add(row);

            DataRow row1 = customerTable.NewRow();
            row1["clsCustomerID"] = "01.2255";
            row1["clsCustomerNM"] = "VSC2_PRE_W1";

            customerTable.Rows.Add(row1); //再加一行


            DataRow row22 = customerTable.NewRow();
            row22["clsCustomerID"] = "01.2311";
            row22["clsCustomerNM"] = "HGC_W1";

            customerTable.Rows.Add(row22); //第三行


            comboBox1.DataSource = customerTable;
            comboBox1.DisplayMember = "clsCustomerNM";
            comboBox1.ValueMember = "clsCustomerID"; //将设置好的datatable 赋值给 comboBox



 

c# 用代码定义带数据的datatable,布布扣,bubuko.com

c# 用代码定义带数据的datatable

标签:style   blog   color   数据   ar   div   代码   new   

原文地址:http://www.cnblogs.com/lthxk-yl/p/3896391.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!