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 / September 2004

Tip: Looking for answers? Try searching our database.

Question on Component

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dotnetjunky - 19 Sep 2004 11:01 GMT
Hi experts,

I created a custom Component in VS.NET 2003. From my component, I need to
catch the Load event of the parent Form. The question is how can I get the
reference to the parent instance, without passing it to the constructor of my
component (because VS.NET designer use default constructor at design-time.)

Thanks in advance.

Dotnetjunky
Stoitcho Goutsev \(100\) [C# MVP] - 20 Sep 2004 15:05 GMT
Dotnetjunky,

AFAIK you can't unless you create your own custom designer and serialize
code that sets the form reference to a property of your component. See how
MainMenu, for example, gets the reference to the form.

Signature

HTH
Stoitcho Goutsev (100) [C# MVP]

> Hi experts,
>
[quoted text clipped - 8 lines]
>
> Dotnetjunky
Dotnetjunky - 21 Sep 2004 02:45 GMT
Hi, thanks for your answer. Here's the next question :-), hope you can help
me too.

So now, I have successfullly hooked up to the parent Form's event. In the
event handler, my component would perform some checking on the machine. If
the check fails, I want to close the Form and exit the main application. If I
call Application.Exit(), nothing happens. If I call parent.Close(), the form
does close, but all the event handlers registered to the form's
Closed/Closing events get fired before that, which I don't want. Not to
mention that the Closing event handlers can stop the form from closing by
setting Cancel property of the CancelEventArgs object to 'false'. How to
workaround this issue ? What I want is close the form immediately without any
other subsequent actions performed.

Thanks in advance.

"Stoitcho Goutsev (100) [C# MVP]" wrote:

> Dotnetjunky,
>
[quoted text clipped - 14 lines]
> >
> > Dotnetjunky
Stoitcho Goutsev \(100\) [C# MVP] - 21 Sep 2004 14:28 GMT
Hi Dotnetjunky,

Do you have more code after Application.Exit? Some code after
Application.Exit might stop the the application from exiting (e.g. showing
message boxes). This has good chances to happen if you have more then  one
Load event handlers. Application.Exit should be the last thing you do before
exit.
Anyways if it is not the case and you can't find out what cause this
behavior you can workaround by calling Environment.Exit instead. But bear in
mind that unlike Application.Exit which stops only the message loops in the
application domain Environment.Exit ends the process. Which in turn means
that if you run more then one application domains in the same process they
will be closed as well.

Signature

HTH
Stoitcho Goutsev (100) [C# MVP]

> Hi, thanks for your answer. Here's the next question :-), hope you can
> help
[quoted text clipped - 40 lines]
>> >
>> > Dotnetjunky
Vlado B. - 22 Sep 2004 15:07 GMT
Hello everyone,

I have the same problem. I want to reference parent form from my component.
I implemented ComponentDesigner but thats all I know and can do.
Can you give me a hint how to find reference through ComponentDesigner (or
some other designer) ???

TIA,

Vlado

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.