Re: Hndling Exceptions From DrapDrop Handler by MortenWennevik
MortenWennevik
Fri Mar 07 07:56:05 CST 2008
I think you have to handle the AllowedEffect of the DragEnter event for this,
and display the effect indicating a drop is not allowed.
--
Happy Coding!
Morten Wennevik [C# MVP]
"Murthy" wrote:
> Hi Morten,
>
>
> I am developing a user control that will be consumed by clients. I want to
> allow users to drag only 1 image and throw an exception when multiple files
> are dragged.
>
> private void richTextBox1_DragDrop(object sender, DragEventArgs e)
> {
> throw (new Exception("can not drag multiple files"));
> }
>
> Now this exception has to be caught by the client of this control and
> display his own message or something like that.
>
> I am currently testing my component with a client i have and ia m trying to
> catch the the exception thrown when multiple files are dragged , but i am
> not able to do so.
>
>
>
>
>
>
>
>
> "Morten Wennevik [C# MVP]" <MortenWennevik@hotmail.com> wrote in message
> news:FF5AD347-9289-4D38-AE4F-5DB1EFB95DF8@microsoft.com...
> >
> > "Murthy" wrote:
> >
> >> Hi All,
> >>
> >> How do i catch the exception that has been thrown from my DragDrop event
> >> handler.
> >>
> >>
> >> The exception is fired from the following function.
> >>
> >> private void richTextBox1_DragDrop(object sender, DragEventArgs e)
> >>
> >> {
> >>
> >> try{
> >>
> >> ///some code....}
> >>
> >> catch(Exceptio e){
> >>
> >> throw ex;}
> >>
> >> }
> >>
> >
> > Hi Mirthy,
> >
> > Since the operating system is running the event method, any exception not
> > caught or thrown will be eaten by the operating system. This happens for
> > all
> > event methods. Whatever you want to do in case of a dragdrop exception
> > you
> > need to do it from the catch block inside the event method.
> >
> > --
> > Happy Coding!
> > Morten Wennevik [C# MVP]
> >
> >
> >
>
>
>