[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Passing startup parameters to child from MDI parent

Posted on 2010-09-09
7
Medium Priority
?
727 Views
Last Modified: 2013-12-17
First time using Multiple Document Interface Windows forms.    

How does one pass startup parameters from the parent?  
Including a URL with examples would be gratefully accepted.

Thank you.
0
Comment
Question by:RichardKline
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Assisted Solution

by:ghayasurrehman
ghayasurrehman earned 500 total points
ID: 33640924
Create new constructors, eg. the code is for a sub form
public class subForm
{
string m_param1;

public subForm()
{
    InitializeComponents();
}

public subForm(string param1)
{
     this.m_param1 = param1;
    InitializeComponents();
}


}

Open in new window

0
 
LVL 1

Author Comment

by:RichardKline
ID: 33641184
Going to be stupid about this. Converting this to vb.net, I have the SUBFORM code below which seems very reasonable.. But how do I code the parent?  

Thank you.

PARENT (does not work).
        Dim NewChild As subform = New subform("thisParameter")
        With NewChild
            .MdiParent = Me
            .Show()
        End With

SUBFORM
Public Class subform
    Private m_param1 As String

    Private Sub subform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Public Sub subform()
        InitializeComponent()
    End Sub

    Public Sub subform(ByVal param1 As String)
        Me.m_param1 = param1
        InitializeComponent()
    End Sub

End Class
0
 
LVL 3

Expert Comment

by:ghayasurrehman
ID: 33641234
what is the error?
have you set parent midcontainer property = true ?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 3

Expert Comment

by:ghayasurrehman
ID: 33641245
or change the constructor as follows
Public Sub subform(ByVal param1 As String)
        InitializeComponent()
        Me.m_param1 = param1
End Sub

Open in new window

0
 
LVL 18

Accepted Solution

by:
John (Yiannis) Toutountzoglou earned 1500 total points
ID: 33641482
if you need to pass parameters form one form to another even if it is MDI parent ,Child you can use the following:
1.using directCast like
Dim f As Form2 = DirectCast(Me.MdiParent, Form2)
f.Text = ...
2.Using Public Variables
3.Or...
'Below the public Class...

Private _passedText As String

    Public Property [PassedText]() As String
        Get
            Return _passedText
        End Get
        Set(ByVal Value As String)
            _passedText = Value
        End Set
    End Property


'so you have label text named LAbel1

Before you open the child set
PassedText=me.label1.text
'....then When you open then child try (let's say in toolstrip Button)
            Dim ChildForm As New Form   'or an existing form 
            ChildForm = FormWindowState.Normal
            ChildForm.MdiParent = Me
'Then in a label control in chikd Form (Named ChildLabel)
            ChildLabel.Text=PassedText   'And there you go

Open in new window

0
 
LVL 1

Author Comment

by:RichardKline
ID: 33642756
Sorry that I could not respond earlier.
ghayasurrehman, Error = VS 2010's Intellisense objected with an "unknown constructor" error.  But this parent code works fine with the subForm code as you presented it.
        Dim NewChild As subform = New subform()
        With NewChild
            .subform("ThisParameter")
            .MdiParent = Me
            .Show()
        End With
*************
jtoutou,
Very Cool.  I knew that you could directcast to/from a child form's element (label, textbox) but that was much too limiting.   Never thought about using Public Properties.  

Thank you, Both!
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33644017
Very Welcome...
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question