问题描述
你好..
我是编程语言的新手。我想要一些帮助..
我想将dataGridView中的选定行传递给类文件。我怎么能这样做..?
贝娄我写了一些我的代码馅饼
frmTest.vb
------------------------- -------------------------
hello..
I am new in programming language. I want to some help..
I want to pass selected row from dataGridView to the class file. how can i do it..?
Bellow I wrote some pies of my code
frmTest.vb
--------------------------------------------------
Public Class frmTest
Dim datarow As DataRow
Dim drObj = New Accepet(datarow)
Private Sub dtg1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dtg1.CellClick
'***I want to code here
End Sub
__________________________________________________________________
我的班级档案是Class1.vb
__________________________________________________________________
My Class file is Class1.vb
Public Sub New(ByVal drDataRow As DataRow)
Try
If drDataRow IsNot Nothing Then
setValues(drDataRow)
End If
Catch ex As Exception
MsgBox(ex)
End Try
End Sub
__________________________________________________
__________________________________________________
推荐答案
dtg1.Rows(e.RowIndex)
确保e.RowIndex有效,因为用户可能已经点击了外面的单元格数据区;即标题或可编辑的新行等......
Make sure that e.RowIndex is valid as the user may have clicked on a cell outside of the data area; i.e. a header or editable new row etc...
这篇关于单击dataGridView上的单元格时如何在DataRow中传递行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!