急求解决!!
我刚学C#,遇到了个问题,求大虾指导:窗体中有一个combox控件,里面自动填充了数据库中的表名,代码如下:SqlConnection myCon = new SqlConnection (@"DataSource=LOCALHOST\SQLEXPRESS;InitialCatalog=ScienceResearch;Integrated Security=True");
SqlCommand selectCMD = new SqlCommand();
SqlDataAdapter custDA = new SqlDataAdapter();
myCon.Open();
selectCMD.Connection = myCon;
selectCMD.CommandText = "SELECT NAME FROM SYSOBJECTS WHERE XTYPE='U';";
custDA.SelectCommand = selectCMD;
DataTable tb1 = new DataTable();
custDA.Fill(tb1);
cbtable.DataSource = tb1;
cbtable.DisplayMember = "NAME";
this.cbtable.DropDownStyle = ComboBoxStyle.DropDownList;
还有一个文本框,如何让在combox中选择的表名显示在文本框里? --------------------编程问答-------------------- DataRowView drv = (DataRowView)comboBox1.SelectedItem;
textbox1.Text= drv.Row["name"].ToString();
--------------------编程问答--------------------
this.textBox1.DataBindings.Add("Text", this.comboBox1.DataSource, "NAME");--------------------编程问答-------------------- --------------------编程问答-------------------- 挺厉害的啊,刚学就这么牛啦! --------------------编程问答-------------------- combox_SelectIndexChange(object sender,EventArgs e)
{
TextBox.Text=combox.Items.SelectedItem.ToString();
}
补充:.NET技术 , C#