Link to home
Start Free TrialLog in
Avatar of David Svedarsky
David SvedarskyFlag for United States of America

asked on

double click datagridview row header to show edit or detail form in VS 2005

Hi,
I need the code to double click a rowheader on a datagridview to show the record in an edit or detail form in Visual Studio 2005.

Thanks,

dave_sky
ASKER CERTIFIED SOLUTION
Avatar of Ariful Ambia
Ariful Ambia
Flag of Bangladesh image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Svedarsky

ASKER

Hi,
Thanks for the response.
I'm just learning so I have a problem that maybe you can help.
Maybe more of a Step by Step, If you would.

My info:
Dataset - "MonarchSQL"
Form - "frmUpgradesList"
Grid - "TblUpgradesDataGridView"
PrimaryKey - "UpgradesKey"

Edit Form - "frmUpgrades"

Your modified Code: (Check my input please)
Private Sub TblUpgradesDataGridView_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TblUpgradesDataGridView.MouseDoubleClick
        Dim I As Int32

        I = e.RowIndex
(Error-'RowIndex' is not a memberof 'System.Windows.Forms.MouseEventArgs'.)
       
 Dim frmUpgrades As New Form
        Dim Textbox1 As New TextBox
        frmUpgrades.Controls.Add(Textbox1)
        frmUpgrades.Show()
        ' to retrive data, for example u can proced in this way
        Textbox1.Text = Me.TblUpgradesDataGridView.CurrentCell.Value
        'or the best way is grabe the the recorde nubmer for the I= e.rowindex and read the data from the database to show it in edit form
    End Sub



I am using VB 2005. u don't get "e.rowindex" in VB 2003

I don't understand, I am using VB 2005!

Your Code:
 I = e.RowIndex

I am getting the error message:
"Error-'RowIndex' is not a memberof 'System.Windows.Forms.MouseEventArgs'."


Hi

U are writting your code in TblUpgradesDataGridView_MouseDoubleClick Event

but u have to wite this code in DataGridView1_RowHeaderMouseDoubleClick Event

You are so right... Pardon me.

 Would you please show the code for this:

>>'or the best way is grabe the the recorde nubmer for the I= e.rowindex and read the data from the database to show it in edit form.

Thanks

Hi

As u can read each and every cell of the double Clicked row Header, u can get the records ID or Index key to find the record in the database. For example CustomerID. When ever u get the customerID u can now search the customer table using the CustomerID to find the respective record and then show it in your edit form.
Hi NomanBD,

Here is what I am looking for:

Form A = Datagridview
Form B = Parent/Child w/ Parent Detail and Datagridview Child.

I want to be able to click on the RowHeader of Form A and show the selected record in Form B.

I have seen it done using a Datagrid instead of a Datagridview using the "MouseDown" event and HitTestInfo.

I think you are trying to show me another type of feature.
Hi
You are right. But the thing is u doesn’t need HitTestInfo approach as we have direct event for getting the mouse click or mouse double click event of a specific row. It is much easier and safer to use those advance events to track down your desire row and corresponding data.

Thanks
Noman