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
dave_skyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ariful AmbiaHead of MISCommented:

    'U can use this code
    Private Sub DataGridView1_RowHeaderMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.RowHeaderMouseDoubleClick
        Dim I As Int32
        I = e.RowIndex
        Dim EditForm As New Form
        Dim Textbox1 As New TextBox
        EditForm.Controls.Add(Textbox1)
        EditForm.Show()
        ' to retrive data, for example u can proced in this way
        Textbox1.Text = Me.DataGridView1.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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dave_skyAuthor Commented:
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
Ariful AmbiaHead of MISCommented:



I am using VB 2005. u don't get "e.rowindex" in VB 2003
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

dave_skyAuthor Commented:

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'."


Ariful AmbiaHead of MISCommented:
Hi

U are writting your code in TblUpgradesDataGridView_MouseDoubleClick Event

but u have to wite this code in DataGridView1_RowHeaderMouseDoubleClick Event
dave_skyAuthor Commented:

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
Ariful AmbiaHead of MISCommented:

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.
dave_skyAuthor Commented:
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.
Ariful AmbiaHead of MISCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Multimedia Programming

From novice to tech pro — start learning today.