|
Hi,
With reference to your query I would like to explain the sequence of Form based events:
INITIALIZE:
This event fires only when an application first creates an instance of a form. In an application with a startup form, the first event that occurs is the startup form's Initialize event. Initialize may also be called well in advance of a Load or Show if, for example, the following statement is executed:
Set x = New Form1
In addition, Initialize is called again if all of the references to the form have been previously set to Nothing and the form is then loaded, shown or has a variable set to it
(for example, Set x = New Form1).
Many of the tasks previously done in the Form_Load statement can, in Visual Basic 4.0, be performed in the Form_Initialize statement. Any statement that needs to be performed a single time when a form is created can be done here. Be careful that you do not reference any of the properties of the controls on the form because doing so will cause an automatic Form_Load.
LOAD:
The Form_Load event fires when a form is first loaded into memory. A form can be caused to load by an explicit Load statement, by calling a Show method when the form is not already loaded, or by a line of code in another module making a reference to any of the unloaded form's properties (or to any properties of the unloaded form's children).
For example, if Form2 is not loaded, and a subroutine in Form1 executes a line of code setting or reading Form2's Caption property, then Form2 will be loaded into memory, and the corresponding Form2_Load event will be called. Unless a form is loaded as a result of a Show method or has its Visible property set to True, the form will be loaded into memory but will not be made visible. Forms can be hidden and shown (using the Hide and Show methods) while remaining in memory; the Load event will only be fired when the form is first loaded.
Some procedures and methods of controls (for example, the SetFocus method) require that their parent form be loaded before they are called. In this situation, the best thing to do is to perform an explicit Form.Show in the Form_Load event, and do any such initialization after calling the Show method. This is preferable to doing the initialization in, for example, the Form_Activate event because Activate is called every time the user switches between forms in an application. Also, if you are calling related events, such as Activate, Paint, or Resize, be careful that their actions do not conflict with the Load and that they don't fire recursive events.
ACTIVATE:
As was stated previously, the Activate event is called every time a form becomes the active window, as long as the focus has moved between forms in the application. The Activate event is not called if the previous window that had the focus was outside of the application.
There are fewer caveats with Activate than with the previous two event procedures, perhaps because Activate is marginally less important than the Initialize and Load events. Code that needs to be executed every time the focus changes within an application should reside in the form's activate event.
I hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
My issue is :
I have a application with more the one windows forms
At one stage in the application i am showing 2 forms, say “Form 1” and “Form 2”..
"Form 2" is called by "Form 1" and "Form 1" is still shown in the back (Not hidden). Now i do some updates in “form 2”, close “form 2” and show “Form 1” back...
On Activate of “Form 1” i was making some buttons disable depending on if “form 2” is shown or not... Hoping that when i come back from “Form 2” activate will be called.. But it is not working..
I even tried calling "form 1's" activate form "form 2's" closed and dispose but no luck...
I can not close "form 1" so i tried with by hiding and showing "form 1" in the function where i am coming back to "form 1", but it dose not worked either
If i take the focus out of “Form 1” and come back it work... as then form activate works..
Can you plz help me
|
|
|
|
|
All of this sounds like your Form1 is showing Form2, waiting for the user to do stuff on Form2, then closing it and returning to Form1. Why not just show Form2 by calling ShowDialog instead of Show ??
|
|
|
|
|
Hi,
I'm reading a XML file that has encoding "windows-1250". But when I run the line:
xmlDocument.load(pathToXml)
I get an error: Invalid character in the given encoding. Line 25, position 62
I have already tried this code, but doesn't work:
fileS = New FileStream(putanjaXml, FileMode.Open, FileAccess.Read)
xmlContext = New XmlParserContext(Nothing, Nothing, "", XmlSpace.Default, System.Text.Encoding.UTF8)
xtr = New XmlTextReader(fileS, XmlNodeType.Document, xmlContext)
xmlDoc = New XmlDocument()
xmlDoc.Load(xtr)
Any ideas how to solve the problem?
Thank you very much!
|
|
|
|
|
Obviously, there's an invalid character in your XML file at the place specified in the error message. As you haven't provided details of the file, I can't be of any further assistance.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hello i have this Structure
Structure Item
dim str as string
dim str1 as string
dim strn as integer
end structure
dim Items() as structure
How can I order the array according to a value of str, str1 or other ?
Tks to all
Fulvio
|
|
|
|
|
In .NET 2.0 you can define a function that does the sorting according to what ever rules you like. You can even write an anonymous function, so that the rules are defined inline.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
I want to display some contents on my windows form ; where contents will continuously move. How to do that?
|
|
|
|
|
If you want to display a HTML page on a windows form, you must use the Webbroswer[^] control.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I am using VB.Net 2005 and ODBC connection to connect with SQL 2000. I can retrieve data using stored procedure ,if it has no parameter.
Now I want to pass parameter How to do that?
|
|
|
|
|
Use the SqlParameter[^] class. Create an instance of this class, configure it and add it to the Parameters collection of your SqlCommand object before executing the query.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I m getting error like: procedure expects parameter which is not supplied
|
|
|
|
|
Did you actually follow my instructions?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Forget using all the ODBC classes and start using the Sql classes (System.Data.SqlClient namespace) instead. The ODBC classes are "generic" and don't take advantage of any of the performance enhancements available when using the native Sql classes.
|
|
|
|
|
My problem is: If i make .exe of my project and install it on another PC then it should take the default SQL server name. If I use SQl class(that is what i m using now) then I have to hardcode my connection string
So i want to use ODBC.
|
|
|
|
|
What are you talking about? You don't hard-code connection strings in your application. You store them in a config file or the registry. There's no reason to be using a generic ODBC connection if your database is SQL Server.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Oh..I m new to programming..
I used configuration file. But I m scared that if by mistake any user makes any changes in that file then my application will not run. Isn't it riskey??
Is this way followed by professionals?
One more question, what is the advantage of ODBC then?
|
|
|
|
|
Master Mind`z wrote: I used configuration file. But I m scared that if by mistake any user makes any changes in that file then my application will not run. Isn't it riskey??
Is this way followed by professionals?
If you are developing a commercial software product, it should have a EULA[^] defined which details the liability limitations for your company if faults occur. Typically, this would state that the end user would be held liable for any problems that arise as a result of improper use of the software. This is something that your management should have put in place, so check with your boss. If you want to store sensitive information in the configuration file you could consider encrypting it, but this causes other problems i.e. where to store the encryption key.
Master Mind`z wrote: what is the advantage of ODBC then?
The advantage of ODBC is its ubiquity. You can use a standard syntax to connect to a wide variety of data sources. This comes at the expense of performance. The generic nature of ODBC means it cannot be optimized for particular providers. This is why you should use the .NET SQL Server provider over ODBC when connecting to a SQL Server database.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thank you so much for the help.
I was using SQl class only but because of this doubt i wanted to switch to ODBC.
Thanks once again!!
|
|
|
|
|
Can anyone please assist me with tutorials or links to sites that can assist me to learn VB.Net faster. I have been using VB 6.0 all along and, thanks to this forum, I understand it's now a dead language.
|
|
|
|
|
hi
i Suggest you buy a Book "Introduction to Vb.net", www.murach.com. Articles or Tutorials covers only certain parts of Vb.net, but if you have a book, it will take you to all the changes you need to know in order to upgrade your Skills. ok, i have a site where you can download a e-book for free , still you must buy a book
http://www.ebooknetworking.com
hope it helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
|
Hai,
I had done one Address Management program in Vb.Net 2005 and Ms-access 2000.
The database consists of only one table with 5000 records in fifteen fields.
I had given one search option to retrive the required data from database.
I didn't use any algorithm in the program.
Simply i had used select query for finding the record.
So that i causes time delay to retrive the record from the database.
I think if i use any Search alogrithm in my program,it will reduce the time delay.
If my idea is correct,please suggest me which alogorithm i can use and how can i implement it my program.
Regards,
G.Manivannan M.Sc.,[IT],
Software Programmer (VBA),
AKUVA Infotech, Bangalore.
|
|
|
|
|
Hi,
Your Idea is right, searching alorithms certainly reduces searching time.
If your data is sorted then you may try to implement the Binary Searh technique.
For more information regarding binary search technique, you may visit the followin link:
http://en.wikipedia.org/wiki/Binary_search[^]
I hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|