Click here to Skip to main content
15,910,277 members
Home / Discussions / C#
   

C#

 
GeneralRe: Grid Veiw Pin
papa198011-Mar-06 22:39
papa198011-Mar-06 22:39 
QuestionDynamic Menu Pin
vatzcar10-Mar-06 3:56
vatzcar10-Mar-06 3:56 
AnswerRe: Dynamic Menu Pin
eggsovereasy10-Mar-06 7:40
eggsovereasy10-Mar-06 7:40 
GeneralRe: Dynamic Menu Pin
vatzcar10-Mar-06 22:17
vatzcar10-Mar-06 22:17 
AnswerRe: Dynamic Menu Pin
Luis Alonso Ramos12-Mar-06 17:52
Luis Alonso Ramos12-Mar-06 17:52 
Questionserializing a class containing hash table as one of its objects Pin
Anupam Mazumdar10-Mar-06 3:33
Anupam Mazumdar10-Mar-06 3:33 
AnswerRe: serializing a class containing hash table as one of its objects Pin
Judah Gabriel Himango10-Mar-06 3:53
sponsorJudah Gabriel Himango10-Mar-06 3:53 
Questiondrag and drop problem Pin
Gyozo Gaspar10-Mar-06 3:20
Gyozo Gaspar10-Mar-06 3:20 
I try to implement drag and drop in .NET FrameWork 2.0. The code below works fine. You have to drag one node onto the other. The problem is that the exception is lost. When I call the failing function via the button everything is fine, the exception comes as expected. But when I do it from drag and drop nothing happens, the exception disappears as if handled by an external code in the FrameWork. Am I doing something wrong?

The form contains only a treeview with two nodes, and a button:

using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace DragAndDropTest<br />
{<br />
    public partial class Form1 : Form<br />
    {<br />
        private TreeNode previousTarget;<br />
<br />
        private void FunctionThatFailes()<br />
        {<br />
            throw new ApplicationException("Something is wrong");<br />
        }<br />
<br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
<br />
        private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)<br />
        {<br />
            treeView1.DoDragDrop(<br />
                treeView1.SelectedNode, DragDropEffects.Move);<br />
        }<br />
<br />
        private void treeView1_DragDrop(object sender, DragEventArgs e)<br />
        {<br />
            TreeNode source = e.Data.GetData(typeof(TreeNode)) as TreeNode;<br />
            TreeNode target = previousTarget;<br />
            ResetPreviousTarget();<br />
            FunctionThatFailes();<br />
            target.Text += source.Text;<br />
        }<br />
<br />
        private void ResetPreviousTarget()<br />
        {<br />
            if (previousTarget != null) {<br />
                previousTarget.ForeColor = SystemColors.WindowText;<br />
                previousTarget.BackColor = SystemColors.Window;<br />
                previousTarget = null;<br />
            }<br />
        }<br />
<br />
        private void treeView1_DragOver(object sender, DragEventArgs e)<br />
        {<br />
            ResetPreviousTarget();<br />
<br />
            if (e.Data.GetData(typeof(TreeNode)) != treeView1.SelectedNode) {<br />
                e.Effect = DragDropEffects.None;<br />
                return;<br />
            }<br />
<br />
            TreeNode target = treeView1.GetNodeAt(<br />
                treeView1.PointToClient(Control.MousePosition));<br />
            if (target == null || target == treeView1.SelectedNode) {<br />
                e.Effect = DragDropEffects.None;<br />
                return;<br />
            }<br />
<br />
            e.Effect = DragDropEffects.Move;<br />
<br />
            if (target == previousTarget) {<br />
                return;<br />
            }<br />
<br />
            previousTarget = target;<br />
<br />
            target.ForeColor = SystemColors.InactiveCaptionText;<br />
            target.BackColor = SystemColors.InactiveCaption;<br />
        }<br />
<br />
        private void Form1_Load(object sender, EventArgs e)<br />
        {<br />
            treeView1.AllowDrop = true;<br />
        }<br />
<br />
        private void button1_Click(object sender, EventArgs e)<br />
        {<br />
            FunctionThatFailes();<br />
        }<br />
    }<br />
}


Gyozo Gaspar
Software Developer
AnswerRe: drag and drop problem Pin
Judah Gabriel Himango10-Mar-06 3:56
sponsorJudah Gabriel Himango10-Mar-06 3:56 
QuestionUpload Pin
albCode10-Mar-06 3:03
albCode10-Mar-06 3:03 
AnswerRe: Upload Pin
Judah Gabriel Himango10-Mar-06 3:58
sponsorJudah Gabriel Himango10-Mar-06 3:58 
QuestionGet connection string in web.config when register RemoteObject on IIS with .Net Remoting Pin
cuong-nm10-Mar-06 2:56
cuong-nm10-Mar-06 2:56 
QuestionProgramming with the XMLDom in C# Pin
ncotton10-Mar-06 2:06
ncotton10-Mar-06 2:06 
AnswerRe: Programming with the XMLDom in C# Pin
Christian Graus29-Jul-07 19:11
protectorChristian Graus29-Jul-07 19:11 
QuestionHow to make a setup project which install two applications Pin
psmukil10-Mar-06 0:10
psmukil10-Mar-06 0:10 
AnswerRe: How to make a setup project which install two applications Pin
spif200110-Mar-06 3:42
spif200110-Mar-06 3:42 
GeneralRe: How to make a setup project which install two applications Pin
psmukil12-Mar-06 18:05
psmukil12-Mar-06 18:05 
AnswerRe: How to make a setup project which install two applications Pin
Libor Tinka10-Mar-06 3:45
Libor Tinka10-Mar-06 3:45 
GeneralRe: How to make a setup project which install two applications Pin
psmukil12-Mar-06 18:04
psmukil12-Mar-06 18:04 
GeneralRe: How to make a setup project which install two applications Pin
psmukil12-Mar-06 18:29
psmukil12-Mar-06 18:29 
QuestionLocking files Pin
Sandrina10-Mar-06 0:04
Sandrina10-Mar-06 0:04 
QuestionMSMQ with .NET 2005 ... question Pin
Yanshof9-Mar-06 22:39
Yanshof9-Mar-06 22:39 
AnswerRe: MSMQ with .NET 2005 ... question Pin
Judah Gabriel Himango10-Mar-06 4:04
sponsorJudah Gabriel Himango10-Mar-06 4:04 
QuestionC# Synthesiser Pin
Sub19799-Mar-06 22:26
Sub19799-Mar-06 22:26 
QuestionSaving a Control's Graphic Content to a Bitmap Pin
sebaaaa9-Mar-06 22:13
sebaaaa9-Mar-06 22:13 

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.