Click here to Skip to main content
15,897,226 members
Home / Discussions / C#
   

C#

 
GeneralRe: A simple paint program-C# Pin
Giorgi Dalakishvili24-Dec-07 23:03
mentorGiorgi Dalakishvili24-Dec-07 23:03 
QuestionHow i can user User Control in my own Form Pin
wasimsharp24-Dec-07 21:23
wasimsharp24-Dec-07 21:23 
AnswerRe: How i can user User Control in my own Form Pin
Xmen Real 25-Dec-07 2:53
professional Xmen Real 25-Dec-07 2:53 
GeneralRe: How i can user User Control in my own Form Pin
wasimsharp25-Dec-07 19:33
wasimsharp25-Dec-07 19:33 
GeneralRe: How i can user User Control in my own Form Pin
Xmen Real 26-Dec-07 0:40
professional Xmen Real 26-Dec-07 0:40 
GeneralPrint Screen Pin
half-life24-Dec-07 20:19
half-life24-Dec-07 20:19 
GeneralRe: Print Screen Pin
Giorgi Dalakishvili24-Dec-07 20:24
mentorGiorgi Dalakishvili24-Dec-07 20:24 
GeneralSystem.ArgumentException Assistance Needed... [modified] Pin
new_phoenix24-Dec-07 13:38
new_phoenix24-Dec-07 13:38 
Hello, guys!!

I am working with an application that uses a try-catch block inside a DragOver Event handler. The problem is that there is an Argument Exception that occurs when a control is dragged. Technically, it is a circular reference. When this Argument Exception occurs, both controls disappear, and the ArgumentException handler catches the error. The question is, how do I get the Exception handlers to prevent the code from running, thereby preventing the controls from disappearing? Is there a way of trapping the condition that causes the ArgumentException so that the controls would not disappear because of the error?

Here is the code:

private static void _ctrlParent_DragOver(object sender, DragEventArgs e)
{
    try
    {
        if (DragDropHandler.CanDropHere((Control)sender, e.Data))
        {
            // Control dragged to
            Control cthis = (Control)sender;
            // Control dragged
            CardControl ctrl = (CardControl)DragDropHandler.GetControl(e.Data, true, true);
            e.Effect = DragDropEffects.Move;

            if (!(ctrl is IDragDropEnabled))
            {
                return;
            }
            if (cthis.Name != ctrl.Name)
            {
                if ((ctrl.HasChildren == false) && (ctrl.blnCardFaceStatus==true)
                    || ((ctrl.HasChildren == true) && (ctrl.blnCardFaceStatus=true)))
                {
                    //MessageBox.Show("cthis is " + cthis.Name + " and ctrl is " + ctrl.Name);
                    ctrl.Parent.Controls.Remove(ctrl);
                    ctrl.Parent = cthis;   // Here is where the circular reference occurs.
                    cthis.Controls.Add(ctrl);
                    ctrl.BringToFront();
                }
                else if ((ctrl.HasChildren == true) && (ctrl.blnCardFaceStatus==false)
                    || ((ctrl.HasChildren == false) && (ctrl.blnCardFaceStatus=false)))
                {
                    return;
                }
            }
            else
            {
                return;
            }
            Point NewLocation = cthis.PointToClient(new Point(e.X, e.Y));
            ctrl.Left = NewLocation.X - dragPoint.X;
            ctrl.Top = NewLocation.Y - dragPoint.Y;
        }
        else
        {
            e.Effect = DragDropEffects.None;
        }
    }
    catch (System.ArgumentException)
    {
        MessageBox.Show("Argument Exception Error");
    }
}


modified on Monday, December 24, 2007 8:12:20 PM

QuestionExcel to XML converter with VC# [modified] Pin
iyepb024-Dec-07 10:03
iyepb024-Dec-07 10:03 
GeneralRe: Excel to XML converter with VC# Pin
Ed.Poore25-Dec-07 14:35
Ed.Poore25-Dec-07 14:35 
GeneralRe: Excel to XML converter with VC# Pin
Waleed Eissa25-Dec-07 17:52
Waleed Eissa25-Dec-07 17:52 
GeneralRe: Excel to XML converter with VC# Pin
yonision8-Jan-10 12:58
yonision8-Jan-10 12:58 
QuestionHow to hide a property from the property grid while still allowing XML serialization Pin
slipster21624-Dec-07 9:52
slipster21624-Dec-07 9:52 
AnswerRe: How to hide a property from the property grid while still allowing XML serialization Pin
darkelv24-Dec-07 14:31
darkelv24-Dec-07 14:31 
GeneralRe: How to hide a property from the property grid while still allowing XML serialization Pin
slipster21624-Dec-07 17:43
slipster21624-Dec-07 17:43 
GeneralRe: How to hide a property from the property grid while still allowing XML serialization [modified] Pin
darkelv24-Dec-07 19:05
darkelv24-Dec-07 19:05 
GeneralPrinting Pin
half-life24-Dec-07 4:48
half-life24-Dec-07 4:48 
GeneralRe: Printing Pin
Xmen Real 24-Dec-07 14:50
professional Xmen Real 24-Dec-07 14:50 
GeneralRe: Printing Pin
half-life24-Dec-07 20:08
half-life24-Dec-07 20:08 
GeneralRe: Printing Pin
Xmen Real 24-Dec-07 20:17
professional Xmen Real 24-Dec-07 20:17 
GeneralProblem to override OnTextChanged(throw Unlimited Loop) Pin
hdv21224-Dec-07 4:39
hdv21224-Dec-07 4:39 
GeneralRe: Problem to override OnTextChanged(throw Unlimited Loop) Pin
Colin Angus Mackay24-Dec-07 4:57
Colin Angus Mackay24-Dec-07 4:57 
GeneralRe: Problem to override OnTextChanged(throw Unlimited Loop) Pin
hdv21224-Dec-07 7:37
hdv21224-Dec-07 7:37 
GeneralRe: Problem to override OnTextChanged(throw Unlimited Loop) Pin
Colin Angus Mackay24-Dec-07 9:20
Colin Angus Mackay24-Dec-07 9:20 
GeneralRe: Problem to override OnTextChanged(throw Unlimited Loop) Pin
hdv21224-Dec-07 12:40
hdv21224-Dec-07 12:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.