List Info

Thread: remove




remove
user name
2006-07-10 02:43:47
>DOTNET-WINFORMS Digest - 7 Jul 2006 to 8 Jul 2006
(#2006-136)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>DOTNET-WINFORMS Digest - 7 Jul 2006 to 8 Jul 2006
(#2006-136)
>
>
>Table of contents:
>
>Handling Events - Multiple Forms/UC's?
>
>
>Handling Events - Multiple Forms/UC's?
>Re: Handling Events - Multiple Forms/UC's? (07/08)
>From: Thomas Freudenberg <infoTHOMASFREUDENBERG.COM>
>
>
>
>
>
>
>
>
>
>
>
>
>Browse the DOTNET-WINFORMS online archives.
>

>From: Thomas Freudenberg <infoTHOMASFREUDENBERG.COM>
>Subject: Re: Handling Events - Multiple Forms/UC's?
>Date: Sat, 8 Jul 2006 11:09:31 +0200
>Generally I declare two c'tors for my Form or UC
classes, one
>parameterless to please the designer, and one taking
parameters as
>desired and calling the previous c'tor. In your case,
I'd write
>
>class MyUserControl
>{
>    public MyUserControl()
>    {
>        InitializeComponents();
>    }
>
>    public MyUserControl(MyMainForm myMainForm) : this()
>    {
>        // do whatever you wan
>    }
>}
>
>Regards,
>Thomas
>
>
>On 7/7/06, Jon Finley <jdfgksys.com> wrote:
>>Hi all,
>>
>>I have an event handling problem that I am sure
there is an answer for, I
>>just can't find it...
>>
>>VS2005/.Net 2.0 Winform Application
>>
>>I have a "main" form, several user
controls on this form, and several
>>"child" forms (although not MDI).  The
main form raises a number of events
>>that I want the user controls to handle. 
Additionally, the user controls
>>are contained inside other controls (Infragistics
dockable window - so
>>Me.ParentForm is not an option).
>>
>>The problem is that the only way the UC's can
detect the main form events
>>is
>>to have a reference to the main form.  This is easy
enough to do by
>>passing
>>the form in the constructor. However; doing this
causes the designer for
>>the
>>main form to break (showing the exception:
"Unable to cast object of type
>>'System.Windows.Forms.Form' to type
>>'GSI.UserInterface.Winforms.DispatcherMain'"
).
>>
>>I've tried creating a public property on the main
form which returns
>>itself.
>>However; the events do not get passed this way.
>>
>>What I would like is a solution that allows the
UC's and other windows to
>>register and handle the events from the main form
without breaking the
>>main
>>form designer.
>>
>>Thanks,
>>
>>Jon
>>
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )