Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

fill textbox in MDI Parent from Global Variable

Posted on 2004-09-06
8
Medium Priority
?
526 Views
Last Modified: 2010-04-23
I have an MDI Winforms App in VB.Net.

When I select a certain Row in the datagrid in the Child Form, I then set a Public Variable (contained in a module) to a certain field value from the database.  Then, on closing the Child form, I want to set the textbox1.text (say) on the Parent Form to the value of that Public Var.

On closing Child form, I tested the Pub Var with a MsgBox - fine - the Pub Var value is correct.
But when I close the Child form, the value does not appear in the textbox on the Parent form.

What 'event' do i need to make this happen?
Is is something to do with using 'Me' object??

Thanks
0
Comment
Question by:Sigh_Man
[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
  • 4
  • 4
8 Comments
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11994881
Hi Sigh_man,

First why use a public variable in a module, just use a public property in your parent form

parent form

Private _mytext As String
    Public Property mytext() As String
        Get
            Return _mytext
        End Get
        Set(ByVal Value As String)
            _mytext = Value
            textbox1.text = _mytext
        End Set
    End Property

child form

    Private Sub yourchildform_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        CType(Me.MdiParent, yourparentform).mytext = TextBox1.Text
    End Sub

Second, you do now that controls on the parent form will ALWAYS be in the foreground.
In other words controls on the parent form are useless.


0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 11996111
Ronald,

I guess I just threw variables into the module because this is the way I first learned to set values and access them using the different forms in my applications.  I guess I just stuck with doing it that way because it answered my problem at the time.  BUT I SEE YOUR POINT!!   :D

Also, your comment...
>>>Second, you do now that controls on the parent form will ALWAYS be in the foreground.  In other words controls on the parent form are useless.

Did you mean to say "In other words controls on the CHILD form are useless"...??  Or am I out of my depth with the terms???!!   :D

In the current application, I have designed my frmMainWindow to have a panel containing text boxes and other stuff.  The idea is that even if a user opens a Child form, they can ALWAYS see certain info about the ActiveClient - surname, Date of Birth etc - all in the panel to the right of the MainWindow.  The Child form does not cover the panel.  The problem is that I need to close the Child Form (say, the 'Set Active Client' form) and once set, I need to close the form and return to the Main Window parent form (which should then be displaying the active Client detail in the panel.
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11996174
Hi Sigh_Man,

No, I meant what I said :-) if you maximize the child form, you will see that the child form is behind the panel.

Do you want to close the child window programaticaly or does the user close the child form.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:Sigh_Man
ID: 11996250
Aaaah, I know what you mean.  Yeah, I'm aware that the Child form will be below the panel on the Parent form.  I have designed the Child Form to accommodate this.  (Is using a panel the best way for this, or is it possible to somehow split the screen, or somehow redefine the MdiChild area on the Parent form (now I really am guessing!)).

And, the user will close the form (for now, at least).
0
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 500 total points
ID: 11996282
(Is using a panel the best way for this, or is it possible to somehow split the screen, or somehow redefine the MdiChild area on the Parent form (now I really am guessing!)).

Unfortunatly no, it would be a great feature though

If the user closes the form you can do as I suggested

parent form

Private _mytext As String
    Public Property mytext() As String
        Get
            Return _mytext
        End Get
        Set(ByVal Value As String)
            _mytext = Value
            mainformtextbox1.text = _mytext
        End Set
    End Property

child form

    Private Sub yourchildform_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        CType(Me.MdiParent, yourparentform).mytext = childformTextBox1.Text
    End Sub
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 11996385
I have just realised that in my Child Form (Set Active Client) the user clicks on the desired client name in a datagrid and hits the "Open" button.  This sets the active client to the one the user selected then closes the Child form -- so in answer to your question, the Child form closes programmatically.  Does this change the solution?
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11996417
not really :-)

The property gets set in the closing event of the child form, so it doesn't matter if it is done manually or programmaticaly
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 11996516
Excellent.

Thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

715 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