Wrox Programmer Forums
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 21st, 2005, 03:53 PM
Registered User
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default C# forms

My application's main form has a status bar that displays user changeable information, setup com ports, gpib stuff, etc. This forms controls (menu and toolbar) creates several other forms that modify these settings which should update the main forms status bar. I have a method in the main form class called UpdateMainStatusBar(). In the close event for the dialog forms I would like to be able to call this method to update the main form status bar but I keep getting compile errors because the dialog form class cannot see this method. I have tried making it a public method to no avail. Can anyone help with this?

Old March 22nd, 2005, 09:08 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma

You will have to cast the variable that holds the reference to your main form class to the type of your main form class to let the other clssses see the function you are trying to call.

E.G. if your main form classe's name is form1 and you are passing the reference of your main class form to other classes as a Form type variable you will have to cast this varible to Form1 before you could call the function you are trying to call.

The neater way however, of doing what you are trying to do is to create a kind of callback function in your main class to update the statusbar and pass references to it ( through delegated) to the other classes.

Ankur Verma

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms and Sub forms Mink Access 1 December 1st, 2004 08:38 AM
Opening forms from other forms Paulsh Access VBA 1 September 30th, 2004 06:54 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.