Hello,
I am trying to make function to get column index from column name of datagridview, if possible.
Without looping through "Columns" collection, of course.
In code I have such situation:
Where program successfully read what is value in named column of current row in datagridview.
So I think my function should be possible but I don't know how to make it.
That of course don't work at all.
Please help for getting my function to work.
I am trying to make function to get column index from column name of datagridview, if possible.
Without looping through "Columns" collection, of course.
In code I have such situation:
Code:
myInt = CInt(DataGridView1.Item("myColName", DataGridView1.CurrentRow.Index).Value)
So I think my function should be possible but I don't know how to make it.
Code:
Private Function GetColIndex(ByVal dgv As DataGridView, ByVal colname As String) As Integer
Try
Return dgv.Item(colname, dgv.CurrentRow.Index).Index
Catch
Return -1
End Try
End Function
Please help for getting my function to work.