private void button1_Click(object sender, EventArgs e) { //using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connStr"].ToString())) //{ // SqlDataAdapter sda = new SqlDataAdapter("Select * From T_Class Where F_Type='Product' order by F_RootID,F_Orders", conn); // DataSet Ds = new DataSet(); // sda.Fill(Ds, "T_Class"); // //使用DataSet绑定时,必须同时指明DateMember // //this.dataGridView1.DataSource = Ds; // //this.dataGridView1.DataMember = "T_Class"; // //也可以直接用DataTable来绑定 // this.dataGridView1.DataSource = Ds.Tables["T_Class"]; //} //甚至直接直接绑定数组 ArrayList AL = new ArrayList(); AL.Add(new myItem("text1", "value1")); AL.Add(new myItem("text2", "value2")); AL.Add(new myItem("text3", "value3")); this.dataGridView1.DataSource = AL; } class myItem { private string _Text; private string _Value; public myItem(string text, string value) { this._Text = text; this._Value = value; } public string Text { set { _Text = value; } get { return _Text; } } public string Value { set { _Value = value; } get { return _Value; } } }
點擊查看更多內容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦