PC Review


Reply
Thread Tools Rate Thread

Child Form setting Parent Form Property

 
 
=?Utf-8?B?am1obWFpbmU=?=
Guest
Posts: n/a
 
      7th Aug 2005
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.
 
Reply With Quote
 
 
 
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      8th Aug 2005
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.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?am1obWFpbmU=?=
Guest
Posts: n/a
 
      8th Aug 2005
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.
>
>

 
Reply With Quote
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      9th Aug 2005
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.

 
Reply With Quote
 
=?Utf-8?B?am1obWFpbmU=?=
Guest
Posts: n/a
 
      9th Aug 2005
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.
>
>

 
Reply With Quote
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      10th Aug 2005
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.

 
Reply With Quote
 
=?Utf-8?B?am1obWFpbmU=?=
Guest
Posts: n/a
 
      10th Aug 2005
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.
>
>

 
Reply With Quote
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      11th Aug 2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
passing data child parent parent child Maarten Microsoft C# .NET 3 21st Nov 2005 05:13 PM
is there an event that fires when a child control is added to a parent container control (ie child panel added to a parent panel)? notu Microsoft Dot NET Compact Framework 1 19th Jul 2005 07:34 PM
setting the parent property from MDI child form in c# =?Utf-8?B?TWVsaXNh?= Microsoft Dot NET Framework Forms 2 20th Apr 2005 01:01 AM
Setting OrderBy for a parent form overrides Filter property of its child Mota Microsoft Access Form Coding 2 5th Dec 2003 01:09 PM
Parent/Child Components: How to make the child components go away when deleting the Parent. Patrick Vanden Driessche Microsoft VB .NET 5 14th Nov 2003 11:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:52 PM.