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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to click on a row in a datagrid, and popup a window, with the id of tat row being passed..?

Thread ID:

Created:

Updated:

Platform:

Replies:

733 Aug 7,2002 04:26 AM UTC Aug 8,2002 07:38 AM UTC WinForms 5
loading
Tags: FAQ
cheryl
Asked On August 7, 2002 04:26 AM UTC

How to click on a row in a datagrid, and popup a form, with the id of tat row being passed to the new form?

Clay Burch [Syncfusion]
Replied On August 7, 2002 08:58 AM UTC

You can can do this in a mousedown event handler for your datagrid using a HitTest to get the row. You can also just use the CurrentRowIndex as weel since there will be a new currentrow at this point.
private void dataGrid1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
	Point pt = new Point(e.X, e.Y);
	MessageBox.Show(this.dataGrid1.HitTest(pt).Row.ToString());
}

cheryl
Replied On August 7, 2002 11:20 PM UTC

> You can can do this in a mousedown event handler for your datagrid using a HitTest to get the row. You can also just use the CurrentRowIndex as weel since there will be a new currentrow at this point. > >
private void dataGrid1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
> {
> 	Point pt = new Point(e.X, e.Y);
> 	MessageBox.Show(this.dataGrid1.HitTest(pt).Row.ToString());
> }
wats HitTest? can pls explain to me? sorry i'm a newbie to VB.NET, but need this urgently for my work.

cheryl
Replied On August 7, 2002 11:23 PM UTC

> > You can can do this in a mousedown event handler for your datagrid using a HitTest to get the row. You can also just use the CurrentRowIndex as weel since there will be a new currentrow at this point. > > > >
private void dataGrid1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
> > {
> > 	Point pt = new Point(e.X, e.Y);
> > 	MessageBox.Show(this.dataGrid1.HitTest(pt).Row.ToString());
> > }
> > wats HitTest? can pls explain to me? sorry i'm a newbie to VB.NET, but need this urgently for my work. And I'm using VB.NET not C leh.. is there any difference?

Clay Burch [Syncfusion]
Replied On August 8, 2002 07:36 AM UTC

Take a look in your help index for HitTest method and then select the DataGrid.HitTest Method. The help there shows VB code for using this method. Here is the link. ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWindowsFormsDataGridClassHitTestTopic.htm

Clay Burch [Syncfusion]
Replied On August 8, 2002 07:38 AM UTC

Another comment is that you don't really need the HitTest as if you click on a row, it normally becomes the currentrow. In that case, the member Me.DataGrid1.CurrentRowIndex will have the row number.

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

;