473,287 Members | 1,926 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,287 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 1980
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.