Discussion Master-Detail Form Help needed!!!

  • Friday, August 01, 2003 8:57 AM
     
     
    Hi,
    I'm new to visual studio...(yes i'm a newbee)
    I've got 2 Forms(Form1,Form2)
    Form1 have an OleDBDataadapter to my database and linkek via a dataset to a dbgrid...
    I want after a dbl click event on 1 row of the form1.dbgrid to open form2 as a detail form of the current row...
    My 2 forms are set but i can't open form2 on the selected item of the form1...form2 always open itself at the first record of the database
    What's the best solution?? bookmark? passing a paramater form to form???
    I need Help!!!
    Thanx

    Francois

All Replies

  • Monday, August 04, 2003 1:42 PM
     
     
    I do this by creating a dataset of the current row and passing it to the dataset of the second form and then when closeing form2 I  merge the datasets back together.


            Me.Cursor = Windows.Forms.Cursors.WaitCursor()
            CurrentTrackingNumber = Me.DataGrid1(DataGrid1.CurrentRowIndex, 0).ToString()
            selIndex = DataGrid1.CurrentRowIndex

            If IsDBNull(CurrentTrackingNumber) = True Then
                MsgBox("No Tracking Number Selected")
            Else
                Dim checkFrm As Form, Opened As Boolean
                For Each checkFrm In Me.MdiChildren
                    If InStr(checkFrm.Text, CurrentTrackingNumber) Then
                        checkFrm.Focus()
                        Opened = True
                    End If
                Next
                If Opened = False Then
                    TicketLoadSetting = 0
                    Dim frm As New TroubleReport()
                    frm.MdiParent = Me
                    Dim RowDS As DataSet = Me.objTroubleReports.Clone()
                    Dim copyRows() As DataRow = objTroubleReports.Tables("tblTroubleReports").Select("TrackingNumber = " & CurrentTrackingNumber)
                    Dim custTable As DataTable = RowDS.Tables("tblTroubleReports")
                    Dim copyRow As DataRow
                    For Each copyRow In copyRows
                        custTable.ImportRow(copyRow)
                    Next
                    frm.objSelectedTroubleReport.Merge(RowDS, False)
                    frm.Show()
                End If
            End If
            Me.Cursor = Windows.Forms.Cursors.Default()
  • Wednesday, August 06, 2003 5:06 AM
     
     
    Thanx joshua for your reply and your detailed code!!! (helpful)

    i'm going to try this...

    Thanx again!!!