(80分求答案)关于vs2003中C#里的dataGrid
你看看,我这个代码
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < dataGridView1.SelectedCells.Count; i++)
listView1.Items.Add(dataGridView1.SelectedCells[i].Value.ToString());
}
private void Form1_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;initial Catalog=spends;trusted_connection=sspi");
con.Open();
SqlDataAdapter sda = new SqlDataAdapter("select * from costs533", con);
DataSet ds = new DataSet();
sda.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
将数据加入到ListBox中就OK了。
思路提供,代码自己搞定。