473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to draw object moving during drag n drop?

I have a custom Panel which will have smaller custom Panels added and drawn
within it. I want to be able to re-order the arrangement of the inner Panels
using drag n drop, and I want to do this graphically by actually drawing the
inner Panel being dragged around, instead of just the default DragDropEffects
graphics.

But I can't seem to get this to work...

What I tried is when you click on an inner Panel you acitvate a DragNDrop
with the panel itself being the Data object. Then in the DragOver event of
the main, outer panel I pull out the inner Panel object and assign it a new
Location, to where the current mouse x,y are. Then I tried calling Refresh
on either and/or both the outer panel and inner panel to no success.

What happens is the inner Panel is drawn initially then as soon as I click
on it to drag it, it disappears and as I drag my mouse over the outer panel
it is never redrawn again.

Any suggestions?

Here's some code...

Within InnerPanel:

void InnerPanel_MouseDown(object sender, MouseEventArgs e)
{
this.DoDragDrop(this, DragDropEffects.Move);
}

Within OuterPanel:

// AllowDrop set to true

void OuterPanel_DragOver(object sender, DragEventArgs e)
{

InnerPanel i = e.Data.GetData(typeof(InnerPanel)) as InnerPanel;
i.Location = new Point(e.X, e.Y);
//this.Refresh(); //tried refreshing outer panel
//i.Refresh(); //also tried refreshing just inner panel
}

InnerPanel has a overriden OnPaint which basically just draws itself as a
roudned ractangle with a thick border. nothing fancy or crazy. It uses an
ExtendedGraphics object to do the rounded rectangle- something someone else
wrote on the Net somewhere

protected override void OnPaint(PaintEventArgs args)
{
Graphics gfx = args.Graphics;

gfx.SmoothingMode =
System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

Pen myPen = new Pen(borderColor);
myPen.Width = 2;
ExtendedGraphics egfx = new ExtendedGraphics(gfx);

Brush brush = Brushes.DarkCyan;

egfx.FillRoundRectangle(brush, 0, 0, this.Width-2,
this.Height-2, 10);
egfx.DrawRoundRectangle(myPen, 0, 0, this.Size.Width-2,
this.Height-2, 10);
}
Sep 6 '06 #1
0 2149

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marco Auday | last post by:
I need to associate items in two listviews. I have got the drag-and-drop operation to perform as I wanted. However, I would like the items in the target listview to be highlighted when the mouse...
0
by: nicomp | last post by:
I studied the Drag and Drop example that all the .Net dev sites link to: a string is dragged from one list box to another. It all makes sense but it doesn't explain how to determine what the object...
16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
2
by: Grey | last post by:
I need to design a workflow application with C#. I want to design an UI with some workflow components which they can be drag & drop anywhere in order to design the workflow for the application...
6
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product...
2
by: murl | last post by:
Im starting on a application that will map fields from an excel file to fields of a sql table for a very small integration project. I have enabled drag and drop on the source listbox, and the form...
9
by: zhaow | last post by:
Hi, All Greetings! I want to develop as appllication that requires a line-drawing function in the blank area between two forms. I have looked up the MSDN, it says that a graphics object need a...
1
by: scf1984 | last post by:
I have this code creating an object to drag-and-drop: window.onload = function() { var dragObject = document.createElement('DIV'); dragObject.id = 'dragObject'; dragObject.style.cssText =...
0
by: kam45 | last post by:
I did one program that draws a line with two squares at the ends and I can just click and extend each ends. It works ok but I need to move the whole line. Would anyone knows how? Private Const...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.