We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Retrieving a row value on double Click of a Datagrid

Thread ID:

Created:

Updated:

Platform:

Replies:

11598 Mar 11,2004 04:05 AM UTC Jun 4,2004 09:42 AM UTC Windows Forms 2
loading
Tags: FAQ
Srini
Asked On March 11, 2004 04:05 AM UTC

I had created a datagrid and bound it with a table in runtime. Now i need to know how can i retrieve the current row value when a user double clicks the datagrid. There is only one column displayed in my datagrid. thanks in advance srini

John
Replied On April 7, 2004 12:54 AM UTC

Try this. ' Create the event handle for the double click Private Sub DataGrid1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick ' get the current row from the Binding Manager Dim bm As BindingManagerBase = Me.DataGrid1.BindingContext(Me.DataGrid1.DataSource, Me.DataGrid1.DataMember) Dim drTemp As DataRow = CType(bm.Current, DataRowView).Row ' you can then retrieve any column's value from the drTemp Msgbox(drTemp(0).Tostring) End Sub > I had created a datagrid and bound it with a table in runtime. Now i need to know how can i retrieve the current row value when a user double clicks the datagrid. > > There is only one column displayed in my datagrid. > > thanks in advance > srini > >

Anonymous
Replied On June 4, 2004 09:42 AM UTC

I am having a problem with this solution, which is similar to FAQ 5.74. My DataGrid (.NET 2003, 1.1) does not have a BindingContext property. There is a similar reference in MS KB Q308070. It might indeed work if I had that property...but is this protected so that I have to expose via a custom class? Other MS documentation discusses using the CurrencyManager object for each grid (I have 3 on one form.) But it appears that you have to manually update the CurrencyManager when a column sort occurs? Any help greatly appreciated. > Try this. > > ' Create the event handle for the double click > > Private Sub DataGrid1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick > > ' get the current row from the Binding Manager > Dim bm As BindingManagerBase = Me.DataGrid1.BindingContext(Me.DataGrid1.DataSource, Me.DataGrid1.DataMember) > > Dim drTemp As DataRow = CType(bm.Current, DataRowView).Row > > ' you can then retrieve any column's value from the drTemp > > Msgbox(drTemp(0).Tostring) > > End Sub > > > > > > I had created a datagrid and bound it with a table in runtime. Now i need to know how can i retrieve the current row value when a user double clicks the datagrid. > > > > There is only one column displayed in my datagrid. > > > > thanks in advance > > srini > > > > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;