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.

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 12:26 AM Aug 8,2002 03:38 AM Windows Forms 5
loading
Tags: FAQ
cheryl
Asked On August 7, 2002 12:26 AM

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 04:58 AM

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 07:20 PM

> 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 07:23 PM

> > 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 03:36 AM

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 03:38 AM

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.

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.

;