Parent - Child Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • truptidalia
    New Member
    • May 2007
    • 13

    Parent - Child Question

    Hello,

    I have a Parent Form and a Child form. In Child form, I perform some search and store the data in Dataset. I want to pass that Dataset in the parent form.

    This is the way i have coded
    ' Parent Form
    Private Sub ShowSrch()
    srchDt = New SearchForm(main Con)
    srchDt.TopLevel = False
    srchDt.Parent = Me
    srchDt.SetBound s(0, 30, srchDt.Width(), srchDt.Height() )
    srchDt.Show()
    End Sub
    Public Sub SetSearchedDs(B yVal sds As DataSet)
    Me.searchedDs = sds
    End Sub

    In child, I tried Me.Parent. but couldn't find SetSearchedDS() . How do i set this, can anone assist me. Any help is appreciated.


    Thanks

    Terry
  • mzmishra
    Recognized Expert Contributor
    • Aug 2007
    • 390

    #2
    Try to get the callerwindow object ,try to get the control and assign the value
    This way you can get the caller window

    if (window.showMod alDialog) { callerWindowObj = dialogArguments ; } else { callerWindowObj = window.opener; }

    Comment

    • Shashi Sadasivan
      Recognized Expert Top Contributor
      • Aug 2007
      • 1435

      #3
      Originally posted by truptidalia
      Hello,

      I have a Parent Form and a Child form. In Child form, I perform some search and store the data in Dataset. I want to pass that Dataset in the parent form.

      This is the way i have coded
      ' Parent Form
      Private Sub ShowSrch()
      srchDt = New SearchForm(main Con)
      srchDt.TopLevel = False
      srchDt.Parent = Me
      srchDt.SetBound s(0, 30, srchDt.Width(), srchDt.Height() )
      srchDt.Show()
      End Sub
      Public Sub SetSearchedDs(B yVal sds As DataSet)
      Me.searchedDs = sds
      End Sub

      In child, I tried Me.Parent. but couldn't find SetSearchedDS() . How do i set this, can anone assist me. Any help is appreciated.


      Thanks

      Terry
      Hi Terry,
      You might need to typecast Me.Parent to your parent form
      So in thour child form
      Code:
      frmParent parentForm = (frmParent)this.Parent;
      parentForm.SetSearchedDS();
      This will work....
      the code is in c#, and below is a converted code (in vb) from one of the sites

      Code:
      Dim parentForm As frmParent = DirectCast(Me.Parent, frmParent) 
      parentForm.SetSearchedDS()
      cheers

      Comment

      Working...