• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3534
  • 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 ITCommented:

    '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 ITCommented:



I am using VB 2005. u don't get "e.rowindex" in VB 2003
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 ITCommented:
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 ITCommented:

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 ITCommented:
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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