我想从 DataGridView 控件填充按钮单击事件的数据:
![enter image description here](https://i.stack.imgur.com/MZ33z.png)
我的代码是这样的
for (int i = 0; i < dgv_EmpAttList.Columns.Count; i++)
{
txt_EnrollNo.Text = this.dgv_EmpAttList.CurrentRow.Cells[i].Value.ToString();
txt_FirstInTime.Text = this.dgv_EmpAttList.CurrentRow.Cells[i].Value.ToString();
txt_LastOutTime.Text = this.dgv_EmpAttList.CurrentRow.Cells[i].Value.ToString();
txt_TotalHours.Text = this.dgv_EmpAttList.CurrentRow.Cells[i].Value.ToString();
}
循环浏览您的列可能不会有帮助。
尝试为每个文本框分配它映射到的单元格:
txt_EnrollNo.Text = this.dgv_EmpAttList.CurrentRow.Cells[1].Value.ToString();
txt_FirstInTime.Text = this.dgv_EmpAttList.CurrentRow.Cells[2].Value.ToString();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)