Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Which Form event is triggered first during application startup?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Jones - 21 Jul 2006 15:10 GMT
Hi,
which Form event is triggered first during application startup? I need
to load data from a database before RowEnter event of a DataGridView
comes to life. I've put the loading code into Form_Load, but that is not
good enough, because RowEnter is triggered sooner. Hence, an exception
is raised when I try to work with the DataSet, which does not contain
any tables yet.

Thanks for any help.

With regards
Paul Jones.
JustinBlat - 22 Jul 2006 05:27 GMT
You may want to consider calling a function from the constructor,
before InitializeComponent is called.

> Hi,
> which Form event is triggered first during application startup? I need
[quoted text clipped - 8 lines]
> With regards
> Paul Jones.
Paul Jones - 22 Jul 2006 10:55 GMT
Justin, thanks for replying...

I'm kind of a newbie, could you please tell me how should I do it
precisely? I piece of code would be great.

Thanks for any further assistance.

With regards
Paul Jones

JustinBlat napsal(a):
> You may want to consider calling a function from the constructor,
> before InitializeComponent is called.
[quoted text clipped - 11 lines]
>> With regards
>> Paul Jones.
Thomas B - 22 Jul 2006 17:42 GMT
All you need to do is place the code inside the Form constructor, like

public Form1()
{
    this.MyDataSet = new DataSet();
    ... code ...
   
    InitializeComponent();
}

That code will execute before any items inside that form even exist.

/Thomas

Paul Jones skrev:
> Justin, thanks for replying...
>
[quoted text clipped - 22 lines]
>>> With regards
>>> Paul Jones.
Paul Jones - 22 Jul 2006 17:58 GMT
Thomas, thank you very much... I'll try it. Just one other question, can
I use MessageBox.Show() here before InitializeComponent() is executed?

Thanks.

With regards
Paul Jones

Thomas B napsal(a):
> All you need to do is place the code inside the Form constructor, like
>
[quoted text clipped - 38 lines]
>>>> With regards
>>>> Paul Jones.
Thomas B - 22 Jul 2006 18:10 GMT
Why don't you try it? ;)
It should work just fine, I've done it in Main() (Program.cs), works
just fine.

Paul Jones skrev:
> Thomas, thank you very much... I'll try it. Just one other question, can
> I use MessageBox.Show() here before InitializeComponent() is executed?
[quoted text clipped - 3 lines]
> With regards
> Paul Jones
Paul Jones - 22 Jul 2006 19:31 GMT
Well, because I'm not able to try it now... :) Nevertheless, you're
right, that was not a good question...

With regards
Paul Jones

Thomas B napsal(a):
> Why don't you try it? ;)
> It should work just fine, I've done it in Main() (Program.cs), works
[quoted text clipped - 8 lines]
>> With regards
>> Paul Jones

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.