能不能把datagridview的数据绑定到窗体把选中的数据记录显示在窗体的文...
发布网友
发布时间:2024-10-16 02:41
我来回答
共2个回答
热心网友
时间:2024-10-21 16:50
可以,像这样写入CellClick函数中
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
textBox1.Text = Convert.ToString(dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value).Trim();
comboBox1.Text = Convert.ToString(dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value).Trim();
dateTimePicker1.Text = Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim();
comboBox2.Text = Convert.ToString(dataGridView1[4, dataGridView1.CurrentCell.RowIndex].Value).Trim();
textBox3.Text = Convert.ToString(dataGridView1[5, dataGridView1.CurrentCell.RowIndex].Value).Trim();
//comboBox18.Text = Convert.ToString(dataGridView1[6, dataGridView1.CurrentCell.RowIndex].Value).Trim();
comboBox3.Text = Convert.ToString(dataGridView1[7, dataGridView1.CurrentCell.RowIndex].Value).Trim();
textBox4.Text = Convert.ToString(dataGridView1[8, dataGridView1.CurrentCell.RowIndex].Value).Trim();
textBox5.Text = Convert.ToString(dataGridView1[9, dataGridView1.CurrentCell.RowIndex].Value).Trim();
textBox6.Text = Convert.ToString(dataGridView1[10, dataGridView1.CurrentCell.RowIndex].Value).Trim();
comboBox4.Text = Convert.ToString(dataGridView1[11, dataGridView1.CurrentCell.RowIndex].Value).Trim();
dateTimePicker2.Text = Convert.ToString(dataGridView1[12, dataGridView1.CurrentCell.RowIndex].Value).Trim();
//dateTimePicker3.Text = Convert.ToString(dataGridView1[13, dataGridView1.CurrentCell.RowIndex].Value).Trim();
textBox7.Text = Convert.ToString(dataGridView1[14, dataGridView1.CurrentCell.RowIndex].Value).Trim();
}
热心网友
时间:2024-10-21 16:46
可以。