473,420 Members | 4,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,420 software developers and data experts.

Want to call a method before visible=true for a form

Hello!!

I have an application that consist of several windows forms. Lets call these
A,B and C for simplicity.
I have one main meny where the user can choose window form A or B or C.

When a user bring up a window for the first time I create an instance
otherwise I just set visible = true.

When a user brings up a window form for example B and the user click on the
little cross
on the system bar I don't want to close the window form but insted hide the
window form
by setting visible = false.
When the user click on the little cross this event handler A_Closing below
is called.
So hide and show for a window form works good and cause no problem.

private void A_Closing(object sender, System.ComponentModel.CancelEventArgs
e)
{
meltPracCommonControl1.CheckChanged();
FormsManager.Instance.getElementYieldForm().Visibl e = false;
e.Cancel = true;
}
Now to my question: Assume you use this visible=true and visible=false and
you have a field on the form which
says firstPosNumber and you write -1 in this field and then you click on the
little cross to hide and then
bring up the same form again you will see -1 in the field firstPosNumber.

What I want to do is when the user bring up the window form for the second
time
I want to use a method that initialize the window form with (correct data
which is read from the db) data. Note I don't want to instance the
window form from the beginning using the c-tor. So for the example with
this -1 when the form was chosen for the second time
the database was read and return 1 in this field firstPosNumber.

So is it possible to have a call to a method that initialize a form before
the form is shown(visible=true).
//Tony
May 11 '06 #1
1 1987
Hi,

"tony" <jo*****************@telia.com> wrote in message
news:Oe****************@TK2MSFTNGP05.phx.gbl...
Hello!!

I have an application that consist of several windows forms. Lets call
these
A,B and C for simplicity.
I have one main meny where the user can choose window form A or B or C.

When a user bring up a window for the first time I create an instance
otherwise I just set visible = true.

Unless the forms have a heavy overload being created I STRONGLY advise you
not to do that. You may get into nasty errors of ownership, parenting, etc.
If for some reason you have to do it, consider using a Singleton pattern for
the form.

Even in this case try to not use ShowDialog but Show when you make a form
visible.
Again, try to avoid this situation

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Stanley J Mroczek | last post by:
I Set the EditCommandColumn to Visible=False to stop people who are not allowed to make any changes to a record. How can set it to Visible=true for some users? Please answer in VB Thanks Stan
1
by: Venkatachalam | last post by:
Hello, I have a c++ dll, whose signature is given below. bapiVersionInfo(char *versionString, UINT size); Where in c++, the caller has to allocate the memory and has to specifiy the size of...
0
by: Andreas Klemt | last post by:
Hello, I have an ASPX Page with 8 Web User Controls on it. Some are Visible = False and some are Visible = True Now I wrote in each Web User Control code: Sub Page_Load() If Me.Visible...
6
by: Nick Stansbury | last post by:
Hi, I have a loop running on Page_PreRender that sets a number of controls to invisible based on a set of criteria. Before I do this however, I set all of the drop down lists to be visible with...
4
by: Martijn Mulder | last post by:
I have a menu option 'Open...' that opens an OpenFileDialog to select an image file to open. Than I need to call Form.Invalidate() to clear the Form and display the image. This happens in a...
2
by: kevintan | last post by:
Hi all, Not sure whether you guys can help. Looking at both forms in javascript below: <html> <head> <script language="Javascript">
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
2
by: Elliot | last post by:
Call a form in a solution is Form1 MyForm = new Form1(); MyForm.Show(); How about call a exe file to be executed?
0
by: calimerotuttonero73 | last post by:
hi, this is the problem : "-2146500594 (800f000e) : method 'form' of object 'subFom' failed " it is displayed when i try to use a Access file. The file was created using ACCESS 2003 ITA and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.