5 Replies - 3130 Views - Last Post: 20 September 2011 - 08:20 PM Rate Topic: -----

#1 Elda  Icon User is offline

  • D.I.C Regular

Reputation: 31
  • View blog
  • Posts: 314
  • Joined: 30-December 10

Datagridview Double Click with edit form

Posted 16 September 2011 - 11:58 PM

Hello...

My Datagridview displays data perfectly. What I want is that
if I click or doubleclick cell of datagrid it will shows my
edit form...

code to displays data


  sqlstmt = "SELECT * FROM GMOIR where " & cbfield.Text & " Like '%" & txtdata.Text & "%' "
       


        Dim cmd As New SqlCommand(sqlstmt, con2)
        da = New SqlDataAdapter(cmd)
        ds = New DataSet
        da.Fill(ds, "CB")
        t = ds.Tables(0)
        dgv1.DataSource = t



Anybody could give link or reference please?

Is This A Good Question/Topic? 0
  • +

Replies To: Datagridview Double Click with edit form

#2 DimitriV  Icon User is offline

  • Don't try to save yourself… the circle is complete
  • member icon

Reputation: 544
  • View blog
  • Posts: 2,632
  • Joined: 24-July 11

Re: Datagridview Double Click with edit form

Posted 17 September 2011 - 12:09 AM

In your DataGridView, add this to your Double-Click sub:
myeditform.show()
'Code to populate edit box fields here


Is this what you meant? Or something else?
HTH
Was This Post Helpful? 0
  • +
  • -

#3 fixo  Icon User is offline

  • D.I.C Regular

Reputation: 83
  • View blog
  • Posts: 335
  • Joined: 10-May 09

Re: Datagridview Double Click with edit form

Posted 18 September 2011 - 11:02 AM

View PostElda, on 17 September 2011 - 12:58 AM, said:

Hello...

My Datagridview displays data perfectly. What I want is that
if I click or doubleclick cell of datagrid it will shows my
edit form...

code to displays data


  sqlstmt = "SELECT * FROM GMOIR where " & cbfield.Text & " Like '%" & txtdata.Text & "%' "
       


        Dim cmd As New SqlCommand(sqlstmt, con2)
        da = New SqlDataAdapter(cmd)
        ds = New DataSet
        da.Fill(ds, "CB")
        t = ds.Tables(0)
        dgv1.DataSource = t



Anybody could give link or reference please?


Take a look at MSDN docs here:

http://msdn.microsof...oubleclick.aspx
Was This Post Helpful? 1
  • +
  • -

#4 Elda  Icon User is offline

  • D.I.C Regular

Reputation: 31
  • View blog
  • Posts: 314
  • Joined: 30-December 10

Re: Datagridview Double Click with edit form

Posted 19 September 2011 - 07:41 PM

Thanks for the reference fixo.
I have this code reading perfectly if rows has data but got error if it
is null.


 Private Sub dgv1_CellDoubleClick

        frmEdit.Show()
        dc = dgv1.CurrentRow.Index
        datafill(dc)

end sub


  Public Sub datafill(ByVal i As Integer)



        r = t.Rows(i)
        frmEdit.txtIrNo.Text = r("IR_No")
        frmEdit.txtDate.Text = r("Date")

End Sub




It says 'Conversion from type 'DBNull' to type 'String' is not valid'..
Was This Post Helpful? 0
  • +
  • -

#5 Elda  Icon User is offline

  • D.I.C Regular

Reputation: 31
  • View blog
  • Posts: 314
  • Joined: 30-December 10

Re: Datagridview Double Click with edit form

Posted 19 September 2011 - 08:47 PM

Got it.... should be like this

frmEdit.txtIrNo.Text = dgv1.Item(0, i).Value.ToString


:)
Was This Post Helpful? 1
  • +
  • -

#6 Elda  Icon User is offline

  • D.I.C Regular

Reputation: 31
  • View blog
  • Posts: 314
  • Joined: 30-December 10

Re: Datagridview Double Click with edit form

Posted 20 September 2011 - 08:20 PM

By the way I'm getting error with this.

 frmEdit.rtDecision.Text = dgv1.Item(10, dc).Value.ToString


It says
"vb.net Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"



:( ?????
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1