Results 1 to 2 of 2

Thread: Pass value back to MDI form from child from (class)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Pass value back to MDI form from child from (class)

    I have created a Windows Application in which one MDI form (frmMainForm) and several child form.
    Application is working fine but Now I want to breake the child forms in a class (.dll) and call them into main project.

    In Current project "mainmodule" - I have assign MDI form as
    HTML Code:
    Public MainForm As New frmMainMenu
    frmMainMenu contain the "StatusBar1" for message display

    In child form (frmComp) I used to display the text in StatusBar panel like -

    HTML Code:
    MainForm.StatusBar1.Panels(2).Text = "Saving Record..."
    Now I create a class file in which copy "frmComp"
    code like -
    HTML Code:
        Public gl_strScreenName As String
        Public gl_strUserName As String
        Public MainForm As System.Windows.Forms.Form
    
    	Public Sub New(ByVal ScreenName As String, ByVal UserName As String, ByVal mForm As Form)
            MyBase.New()
    
            'This  is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() 
    
        End Sub

    But code like earlier show error message "'StatusBar1' is not a member of 'System.Windows.Forms.Form'" -
    HTML Code:
    MainForm.StatusBar1.Panels(2).Text = "Saving Record..."
    Pls guide how to rectify the error and display the message in statusbar panel

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Pass value back to MDI form from child from (class)

    First change your way of thinking. At the moment you're trying to get your form to push a status to the parent form directly. As you've discovered, that doesn't work for a number of reasons... 1) it's just bad juju to begin with. The form shouldn't care if it's a child form or a parent form or a stand alone form... 2) "MainForm" is just a form... a basic, empty and generic ordinary run of the mill, garden variety form. It's got nothing on it... that's why the attempt a calling STatusBar1 on it fails...

    What you should be doing is in your child form(s), is creating an event, for example "ChangeStatus" ... and then raising that event along with the message you want to send as the status. Then in the main form, when you instanciate the child form, also wire up the event to the appropriate event handler, which then can take hte message and send it to the StatusBar properly.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width