• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3568
  • Last Modified:

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
0
dave_sky
Asked:
dave_sky
  • 5
  • 4
1 Solution
 
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
0
 
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
0
 
Ariful AmbiaHead of MISCommented:



I am using VB 2005. u don't get "e.rowindex" in VB 2003
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy 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'."


0
 
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
0
 
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
0
 
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.
0
 
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.
0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now