Wednesday, August 11, 2010

VB code: Select a row in a datagrid then link to a form?

I'm using an ADO control. I am doing a library system.I have a search button the shows the result in a datagrid. What I want is to select a row from the datagrid then link it to a new form. This new form will also use the values in the row like the FristName, Surname, etc. How would I do this?VB code: Select a row in a datagrid then link to a form?
Code the mouse click event on the datagrid to fire and pass the information to your new form





Excuse the code, it's not well written but it will get you the results you want.








Mouse Code:





Private Sub dg_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dg.MouseDoubleClick





frmNewForm.loadInfo(dg.Rows(dg.


SelectedRows


(0).Index).Cells(';FirstName';), dg.Rows(dg.SelectedRows


(0).Index).Cells(';LastName';))





End Sub








Then on your second form have the relevent method to call





Public sub loadInfo(byref sFirst as string, byref sLast as string)





txtFirstname.text = sFirst


txtLastname.text = sLast


me.show





end sub
  • love myspace
  • myspace girl
  • No comments:

    Post a Comment