Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi,

Do u have an example for me to be able to double click a win datagrid and pick up the values in the cells for that row

Thanks

Edited by farshad
Farshad
Posted (edited)

Here you go:

 

        Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseDown
	
	Dim hitInfo As DataGrid.HitTestInfo = sender.HitTest(e.X, e.Y)

	'Here is the code to get one cell
	If hitInfo.Type = DataGrid.HitTestType.Cell Then
		MsgBox(sender.Item(hitInfo.Row, hitInfo.Column))
	End If

	'Here is the code to get the whole row
	Dim i As Integer
	If sender.BindingContext(sender.DataSource, sender.DataMember).Count > 0 Then
		Dim bm As BindingManagerBase = Me.BindingContext(sender.DataSource, sender.DataMember)
		For i = 0 To CType(bm.Current, DataRowView).Row.ItemArray.Length - 1
			MsgBox(CType(IIf(IsDBNull(bm.Current(i)), "(null)", bm.Current(i)), String))
		Next
	End If
End Sub

Edited by bfellwock

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...