Child Form setting Parent Form Property

Discussion in 'Microsoft Dot NET Framework Forms' started by Guest, Aug 7, 2005.

  1. Guest

    Guest Guest

    I have a MDI Windows Form application, within it I have three child forms
    that allows a user to provide about 5 paragraphs of text. Instead creating a
    large multi-line text box on the child form, I created a "Detail" form, which
    contains the large textbox, that the three forms can share.

    This detail form is reused by all three forms to capture the user text. I
    intended to pass the child form name and child form property in the detail
    constructor, then at runtime have the form pass the user text back to calling
    form.

    Unfortunately because the three forms that are calling the shared Detail
    form are child forms of the master mdi form, I can't set them as
    mdiContainers, so I can't call the mdiParent parent property in the Detail
    Form.

    Ideally my code would look something like this:

    Form that calls Detail Form:

    Form that calls Detail Form:
    Friend WriteOnly Property Statement() As String
    Set(ByVal Value As String)
    mStatement = Value
    End Set
    End Property

    Private Sub btnStatement_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnStatement.Click
    Dim detail As New detail(me.getType, "Statement")
    detail.ShowDialog()
    End Sub

    The Detail Form code:

    Public Sub New(ByVal FormType as Type, ByVal FormPropertyName As String)
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    mFormType = FormType
    mFormPropertyName = FormPropertyName
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnSave.Click

    [mFormType].[mFormPropertyName].txtUserText.Text 'Pseudo Code
    ' Hard Code would be: AppName.ChildFormName.Statement =
    txtUserText.Text

    End Sub

    Any thoughts on how to accomplish? Please post code samples in VB. Thanks.

    Josh.
     
    Guest, Aug 7, 2005
    #1
    1. Advertisements

  2. Hi Josh,

    Thanks for your post.

    Yes, just as you find out, we can not place a MDI child form as another
    form's MDI container, this is by design.

    Based on my understanding, the cause you want to use Detail form is that
    you want to share this form(Textbox function) code across 3 child forms. If
    so, I think we may have 2 other ways:
    1. Create a usercontrol, which has the same function as Detail form. That
    is placing a TextBox on that Usercontrol, and in 3 MDI child forms, we can
    dynamically construct this Usercontrol and adjust its position correctly to
    fit our need.
    2. Actually, I think we can just inherit the build-in TextBox and create a
    customized large multiline TextBox with the function we need. Then we can
    just reuse this customized TextBox in all the 3 MDI child forms.

    Does this meet your need? If I misunderstand you, please feel free to tell
    me, thanks
    ========================================
    Thank you for your patience and cooperation. If you have any questions or
    concerns, please feel free to post it in the group. I am standing by to be
    of assistance.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jeffrey Tan[MSFT], Aug 8, 2005
    #2
  3. Guest

    Guest Guest

    I'm limited on space on the 3 child forms, so I wanted to popup a detail form
    to capture the text. Since the form has the same functionality I wanted to
    reuse the form. Thanks.

    Josh.

    ""Jeffrey Tan[MSFT]"" wrote:

    > Hi Josh,
    >
    > Thanks for your post.
    >
    > Yes, just as you find out, we can not place a MDI child form as another
    > form's MDI container, this is by design.
    >
    > Based on my understanding, the cause you want to use Detail form is that
    > you want to share this form(Textbox function) code across 3 child forms. If
    > so, I think we may have 2 other ways:
    > 1. Create a usercontrol, which has the same function as Detail form. That
    > is placing a TextBox on that Usercontrol, and in 3 MDI child forms, we can
    > dynamically construct this Usercontrol and adjust its position correctly to
    > fit our need.
    > 2. Actually, I think we can just inherit the build-in TextBox and create a
    > customized large multiline TextBox with the function we need. Then we can
    > just reuse this customized TextBox in all the 3 MDI child forms.
    >
    > Does this meet your need? If I misunderstand you, please feel free to tell
    > me, thanks
    > ========================================
    > Thank you for your patience and cooperation. If you have any questions or
    > concerns, please feel free to post it in the group. I am standing by to be
    > of assistance.
    >
    > Best regards,
    > Jeffrey Tan
    > Microsoft Online Partner Support
    > Get Secure! - www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
    >
     
    Guest, Aug 8, 2005
    #3
  4. Hi Josh,

    Thanks for your feedback.

    Sorry, but I do not think I understand your meaning. I can not see why in
    your scenario we must use a detail form. Why we can not use an inherited
    form or a UserControl?

    Hope you can clarify your concern to me. Thanks

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jeffrey Tan[MSFT], Aug 9, 2005
    #4
  5. Guest

    Guest Guest

    Here is the big picture:

    * One Master MDI Parent Form
    * Three child forms that have limited space on the form
    * A separate shared X form that can be used by the child forms to obtain
    text details from the user.

    How do implement X form so that I can refer back to the calling form
    dynamically, opposed to hard-coding each form name and property in the X
    from. I'm open suggestion on which apporach to take. Thanks.

    Josh.

    ""Jeffrey Tan[MSFT]"" wrote:

    > Hi Josh,
    >
    > Thanks for your feedback.
    >
    > Sorry, but I do not think I understand your meaning. I can not see why in
    > your scenario we must use a detail form. Why we can not use an inherited
    > form or a UserControl?
    >
    > Hope you can clarify your concern to me. Thanks
    >
    > Best regards,
    > Jeffrey Tan
    > Microsoft Online Partner Support
    > Get Secure! - www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
    >
     
    Guest, Aug 9, 2005
    #5
  6. Hi Josh,

    Thanks for your feedback.

    Is your concern on "How do implement X form so that I can refer back to the
    calling form dynamically"? If so, I think we can create a constructor for
    form X with one parameter of type Form(In the constructor, we can store the
    parameter in a class field). Then whenever we create our the form X, we can
    pass the calling form's reference as the constructor parameter. So we can
    get the calling form reference with the class field.

    Hope this helps.
    =======================================
    Thank you for your patience and cooperation. If you have any questions or
    concerns, please feel free to post it in the group. I am standing by to be
    of assistance.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jeffrey Tan[MSFT], Aug 10, 2005
    #6
  7. Guest

    Guest Guest

    Yes. I tried the ByRef with the constuctor but I couldn't get that to work.
    In addition to passing the form name, I would like to pass the property name
    that needs to be set and a default value for the textbox.

    The call from the child would look something like this:

    Dim detail As New detail(me.getType, "Statement", textVal)
    detail.ShowDialog()

    Where the first parameter is the form name, the second is the property name,
    and the third is any text to populate the form.

    Thanks.

    Josh.

    ""Jeffrey Tan[MSFT]"" wrote:

    > Hi Josh,
    >
    > Thanks for your feedback.
    >
    > Is your concern on "How do implement X form so that I can refer back to the
    > calling form dynamically"? If so, I think we can create a constructor for
    > form X with one parameter of type Form(In the constructor, we can store the
    > parameter in a class field). Then whenever we create our the form X, we can
    > pass the calling form's reference as the constructor parameter. So we can
    > get the calling form reference with the class field.
    >
    > Hope this helps.
    > =======================================
    > Thank you for your patience and cooperation. If you have any questions or
    > concerns, please feel free to post it in the group. I am standing by to be
    > of assistance.
    >
    > Best regards,
    > Jeffrey Tan
    > Microsoft Online Partner Support
    > Get Secure! - www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
    >
     
    Guest, Aug 10, 2005
    #7
  8. Hi Josh,

    Yes, you should pass the information you needed to the form's contructor.

    If you still have any concern, please feel free to tell me, thanks

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jeffrey Tan[MSFT], Aug 11, 2005
    #8

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marina Neyman

    MDI - how to open a child from a child within MDI parent form?

    Marina Neyman, Feb 7, 2004, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    894
    Marina Neyman
    Feb 7, 2004
  2. Marina Neyman

    MDI - how to open a child from a child within MDI parent?

    Marina Neyman, Feb 7, 2004, in forum: Microsoft Dot NET Framework Forms
    Replies:
    1
    Views:
    603
    Bernie Yaeger
    Feb 7, 2004
  3. Wesam
    Replies:
    2
    Views:
    401
    Wesam
    Jun 22, 2004
  4. Guest

    RE: Open parent window then child window - parent loads after?

    Guest, Aug 4, 2004, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    462
    Guest
    Aug 4, 2004
  5. Guest

    setting the parent property from MDI child form in c#

    Guest, Jan 22, 2005, in forum: Microsoft Dot NET Framework Forms
    Replies:
    2
    Views:
    813
    Guest
    Apr 20, 2005
Loading...

Share This Page