本文介绍了数据网格视图单元格内容单击错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我创建了2个表单1.EmpPerInfo 2.Search,当用户点击EmpPerInfo表单的搜索按钮时,将打开搜索表单。然后用户将放置EmpNo。 &安培;点击查找按钮。然后匹配的行/记录将显示在Gridview中。 上述步骤的代码工作正常。但现在我想要用户点击名称数据网格视图系统的列将显示EmpPerInfo形式的记录,我已经写了下面提到的代码。I have created 2 forms 1.EmpPerInfo 2.Search, When user click on "Search" button of EmpPerInfo form then Search form will be open. Then user will put EmpNo. & click on find button.Then matched row/record will be displayed in Gridview.Code for above mentioned steps are working fine.but Now I want when user click on Name column of Data Grid View system will show that record in "EmpPerInfo" form for this i have written below mentioned code.Private Sub DataGridView1_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles EmployeeGrid.CellContentClick If (e.ColumnIndex <> -1) Then If (e.RowIndex > -1) Then EmpNo = e.RowIndex EmpPerInfo.txtSrn.Text = dt.Rows(EmpNo).ItemArray(0).ToString() EmpPerInfo.txtFullName.Text = dt.Rows(EmpNo).ItemArray(2).ToString() EmpPerInfo.Show() End If End If End Sub 但是EmpPerInfo.txtSrn.Text = dt.Rows(EmpNo).ItemArray(0).ToString()在此语句系统中引发错误位置0没有行 。but "EmpPerInfo.txtSrn.Text = dt.Rows(EmpNo).ItemArray(0).ToString()" at this statement system throws an error "There is no row at position 0".推荐答案Private Sub DataGridView1_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles EmployeeGrid.CellContentClick If (e.RowIndex > 0) Then EmpNo = e.RowIndex EmpPerInfo.txtSrn.Text = dt.Rows(EmpNo).ItemArray(0).ToString() EmpPerInfo.txtFullName.Text = dt.Rows(EmpNo).ItemArray(2).ToString() EmpPerInfo.Show() End If End Sub 这篇关于数据网格视图单元格内容单击错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-05 06:12