473,785 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET 2005 Winforms Form Load Event

2 New Member
Hello all

In VB6, if you referred to a property or a some property of a control
of an unloaded form, it caused a form_load, and fired the Form_Load event.

I have a lot of code that depends on this behaviour: thus in order to achieve some initialization of my form , I have a general purpose routine as follows
Expand|Select|Wrap|Line Numbers
  1. Public Function ShowForm(ByRef FormToShow As Object, ByRef ShowModal As Boolean, ByRef FormTag As String) As Boolean
  2.     ' routine shows a modal form: loads form and activates it before displaying
  3.     Dim ModalState As Byte
  4.     ModalState = IIf(ShowModal, VB6.FormShowConstants.Modal, VB6.FormShowConstants.Modeless)
  5.     With FormToShow
  6.       ' FormTag parameter indicates what state to load the form in
  7.       .Tag = FormTag ' triggers Load event
  8.       ' manually force code called by Form_Activate routine to execute before showing form
  9.       ' note: must be a public function
  10.       '2/7/01 CG Make the function FormInitialize a boolean one whereever it occurs; if it returns false, unload the form instead of showing it.
  11.       'FormInitialize is a public boolean function in any form which is shown by this routine
  12.       'It will typicall use the value of the form's tag, set above to perform initialization tasks
  13.       If .FormInitialize Then
  14.       'If the form's FormInitialize function returns true, show the form in the modal state indicated in the ShowModal parameter
  15.         VB6.ShowForm(FormToShow, ModalState)
  16.         ShowForm = True
  17.       Else
  18.         FormToShow.Close()
  19.       end if
  20.    end With
  21. End Function
  22.  
In VB6 line 7 .Tag = FormTag would set the form's tag to FormTag and force a form_load: this does not seem to happen in VB.NET 2005

Is there anyone out there who can give me some insight into this? I would have thought that the behaviour, much complained of in other places, almost had to be like that: what does it mean to refer to the .TAG property of a form that is not loaded?
By way of experiment, I have tried setting other properties of the form in this routine, but the form_load will not fire in these cases either.

Thank you

Charles Geach.
Sep 6 '07 #1
2 7029
Plater
7,872 Recognized Expert Expert
The Tag property in .net is just a scratch space to store extra data (as far as I can figure)

Generally:
Expand|Select|Wrap|Line Numbers
  1. Dim form1 As New Form1() 
  2. form1.Show()
  3.  
will show the form and trigger the LOAD event
Sep 6 '07 #2
CSGeach
2 New Member
The Tag property in .net is just a scratch space to store extra data (as far as I can figure)

Generally:
Expand|Select|Wrap|Line Numbers
  1. Dim form1 As New Form1() 
  2. form1.Show()
  3.  
will show the form and trigger the LOAD event
Well, thank you: the tag property in VB6 was the same. The thing is that I want to do some initialization before the form is shown, and in fact only show the form if that initialization succeeds.
As I said in my code snippet, referring to any property or control of the form would in VB6 trigger the form load.

Thank you again for any further insight into this
Sep 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
7399
by: STom | last post by:
I have a C# Winforms app that has 5 Winforms, lets say A through E. A: Data entry. When data is entered here in any field, values are updated on forms C, D, E.(Not B) B: Data entry form. When data is entered here in any field, values are updated on forms C, D, E (not A). I am considering using delegates to fire events from forms A & B. In forms C, D, E I will have functions with the same signature and even the same name that just...
7
17759
by: Ori | last post by:
Hi, I would like to create some mechanism to handle all the exceptions which will happen in my application. I have one form which is the base form while all the other forms inherit from it. I try to find a way to "register" the base form to the Error handling , but I don't know how….
5
8212
by: Tarun Mangla | last post by:
Hi I am facing a problem. I've made an application in which two forms are there. One if Login form and another is main form. The problem is that, after getting authenticated from the database the main form is opened. But the login form is not getting closed. I am using the following code: It is in the load of the main form. this.ParentForm.Close();
2
2021
by: Kurt Denhoff | last post by:
I have an odbc connection on a Winforms UserControl when used within a WinForms project it works fine but when I use it on an aspx page the object doesn't show. The IIS log indicates code 200(successfully loaded). I am suspecting this may be an issue with being fully trusted dll. I experimented with the ODBC connection on a Webform control - it worked fine. I put the ODBC connection on the aspx page - it worked fine. I put the...
10
2146
by: Chad Miller | last post by:
I currently have a base form that I inherit. The base for has a custom event. The event will not raise threw the inherited form. I was wondering if events work threw inheritance or should I use some other method? -- Chad Miller President and Director of Software Development Predictive Concepts, Inc. www.predictiveconcepts.com 407.327.9910
0
931
by: guy | last post by:
Two of us are working on a Winforms solution (5 projects) and are using VSS, and VB.NET 2003 with one form, regularly on closing it in design mode, or sometimes on checking it in, Sourcesafe prompts for to do a check out for edit even though an edit is not required. it will then not allow a check out Cancel. If the checkout is allowed then most of the controls, primarily those on tab pages or panels. drop off the form. The controls still...
27
1941
by: Rene | last post by:
I keep getting the following error every time I compile the solution under VS 2005: ---------------- Error 5 Unable to copy file "obj\Debug\xyz.dll" to "bin\Debug\xyz.dll". The process cannot access the file 'bin\Debug\xyz.dll' because it is being used by another process. ----------------
2
1117
by: dgk | last post by:
I want to use certain events but only when the form is finished with the Load event. Obviously I can set a boolean flag but I was looking around for anything in Me that might do the same thing but I don't see it. Did I miss it?
4
5988
by: parez | last post by:
Hi, Whats the winforms equivalent of asp.net page load event? I am trying to clear a status message field every time a user clicks on any of the buttons..
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10104
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.