Learning to drag and drop buttons in Winforms - c#

I am currently trying to learn how to use Drag and Drop functionality in C# winforms. I've found some pretty neat tutorials and documentation online, but none that have helped steer me in the direction of a solution for my current problem.
To break my design goal down into just a simple example- I basically have a windows form that is split in half. There are regular ol' button controls on the left half, and nothing on the right. My goal is to be able to drag a button from the left side and drop it on the right. Doing so will grey out the button on the left side, and have the button now shown on the right. It doesn't have to show up wherever it was dropped on the right side- it can just appear in a preset location if necessary. I just want to be able to copy buttons from the left to right side.
Now, with that said- can anyone think of documentation, tutorials or anything else that might help steer me on the right track to figuring out how to do this? So far I've found that I'll need events for picking it up and putting it down, but beyond that I'm at something of a loss!
Normally I try to have more details in my questions, but since there is really nothing else to the program at this point I don't have much by way of code to show! So sorry for the somewhat vague question!
Thanks!

See Walkthrough: Performing a Drag-and-Drop Operation in Windows Forms
Edit: Changed link to english version

Check out this drag-and-drop walkthrough: http://msdn.microsoft.com/en-us/library/za0zx9y0.aspx [english]

Related

C# Winform How to Pin/UnPin WebBrowser control

I have a web browser control embedded in a tabPage in my application. How do I drag it out of my desktop app, that is an option to dock/undock or unpin it.
Edit: After reading a bit, I think I should do this with DragDrop events. I saw several examples to drag and drop within an application or between applications, but I am wondering if it is possible to drag the control outside my application to another screen. Should I record the screen coordinates to do this?
Edit: So far I have tried to capture MouseUp/MouseDown events with a simple button control but that only helps with moving the control within the form.
When I was reading DragDrop documentation in MSDN, it says 'AllowDrop' needs to be set to the target. But my target is not limited to a form it can also be a desktop screen. It makes me think I am totally on the wrong route. I am not pasting any code because I believe I am looking for an approach or some suggestion to do this. I am a novice so if this is not clear, please ask me further questions.
Hoping to hear from someone.
Thanks!
If anyone is interested, this codeproject link helped me get started:
http://www.codeproject.com/Articles/15418/PullApartTabPage-Docking-and-Undocking-Your-TabPag

Create a popover-like control in C# WinForms?

So, one of my favorite things about iOS/ObjC in general is the "popover" control.
I am building an app in C# WinForms that would benefit greatly from this type of control- anyone have any ideas on how I might be able to emulate this type of look?
For reference, here's an example screenshot of what I'm talking about http://i.imgur.com/IzbbzrA.png
Thanks for any ideas!
You can create a simple popup control by following the articles linked below
Simple Popup Control
I don't think such a control exists in .Net. What I would do from this point if I were you is try to making one using a customized windows form on top of it. Play with the Mouse Hover events of the control and make the form appear for a short time. Make it without borders. With a little imagination you can have your own version of the PopOver.

Tool Strip wont stretch and autofit, according to the window! (in c#, using Visual Studio 2010)

I am a beginner coder and I have a major problem when I am coding my browser. The problem is basically all thanks to the tool strip.
Here is my problem:
1) When I was designing all the stuff, I arranged all the buttons and text boxes!
When I ran my program, it was all working good. Take a look at the picture.
http://i.stack.imgur.com/5GHZ8.png
And now...
2) Now, after I pressed the maximize button, things were badly unarranged...! Take a look at the picture !
http://i.stack.imgur.com/cfVUK.png
Now what should I do? Please help!
Hi there and welcome to C# and StackOverflow!
You need to be able to tell Visual Studio which element will get resized with the window and which elements will stay at the same width, etc. This is done using LayoutPanels, in your case best suited is TableLayoutPanel. You can then dock all elements in their appropriate table cells and tell the cells how to size (you can even use proportions!). You can of course make the second row the area, where the web page is displayed and tell the first cell to span across all columns ( http://msdn.microsoft.com/en-us/library/ms171687%28v=VS.80%29.aspx ).
There's a guide here: http://msdn.microsoft.com/en-us/library/w4yc3e8c%28v=VS.80%29.aspx

Windows Forms advanced visual effects

I have an design idea about the appearence of a small program , which is basically a windows form with a combo and one button.What i would like to do is the following.When i click on the .exe of the program to start it , i would like to have an non-standart start up of the window.To be more specific i will give you an example - i click on the .exe , upon which some dots appear in a random matter all over the screen , after those points appear they start moving in a spiral way so finally they merge into the standart square windows form shape.So my question is - is there a free API or anything similar with the help of which its easily doable or there would be a lot of work needed from myself to create those API's ?
Thanks in advance
This will be extremely difficult to do.
It will also be very annoying for the end-users.
In short I see two options:
Render your form to a bitmap and render peices of the bitmap to a full-screen layered window. You'll have to call UpdateLayeredWindow repeatedly to get the animation working but that should be a good lead. I could see getting 10-20 fps with this method.
Take a screenshot of the desktop, create a full screen borderless topmost window, render the screenshot, then render your animation on top. This will prevent any other windows from recieving input while the animation is playing.
Either way your users will hate you.
As SLaks has already said, that will be pretty annoying for the end-users.
If you ask whether it is doable, I would say yes, everything is doable in programming, it all depends on the effort you're ready to put into.
As a very simple algorithm, here are some steps I would go through for your achievement:
Create a System.Windows.Forms.Form;
Set Form.ShowInTaskBar= false;
Set the Form.TransparencyKey property;
Set the Form.ControlBox= false;
Set Form.TopMost= true;
Drop a PictureBox control on your Form;
On the Form.Load event, take a screenshot of the current desktop and set it as the image of your PictureBox.
Then, build an animated GIF, and superpose it to your form.
You will most likely appreciate, I guess, the following link which discusses about C# Winforms Animation.
Disclaimer: This is an arbitrary algorithm off the top of my head. Besides, I illustrated the steps I would go through in order to achieve such objective, though I have never ever performed WindowsForms animation.
Althouth this might be cool to program, users are conservatives and "always anxious" about program startups, so, as already mentioned, this might become pretty annoying for the end-users.
I hope this helps you through anyway!

Free Windows Forms Components Similar to jQuery UI Draggables

EDIT:
So, I ended up making my own basic solution to this problem, and it can be found in my own answer to the question below. Or, here's a link.
Original Post
I'm doing some UI programming for a small .NET application. The application has some collections of items that need to be displayed in a grid sort of format (X columns by Y rows) and the grid elements need to be able to get dragged around to different grid locations, and possibly out of the grid all together.
The most comparable sort of UI design elements I can think of are the jQueryUI Draggables.
Do I have to roll my own or are there components people have already written to act like this? Even better, are there any free components? Or is there an easy way to do this that I just don't know about (don't do a lot of .NET UI programming..)
Also these "grid items" need to be able to include windows form components. The DataRepeater control is close to what I need, except it only supports horizontal or vertical alignments, not grids of items.
Here's a visual example of what I'm looking for:
I tried to stick with a halloween theme here.
Well I rolled my own solution and hosted it on GoogleCode:
draggableitemorderedpanel- A .NET Winforms Component... Kinda like jQuery UI Draggables (not really, maybe someday)
here's a screenshot:
(source: googlecode.com)
and another just resized:
(source: googlecode.com)
Hope this helps someone else out. Also it's super basic and pretty sucks right now but gets the job done.
Anyone that wants project access can have it.
The System.Windows.Forms.TableLayoutPanel control supports dragging and dropping, you just have to handle the right events. You could make your own "GridItem" user control, with the icon, caption, background color, etc displayed on a Panel, and then plop a bunch of them in the tablelayoutpanel, and wire up some event handlers. Here's something similar:
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/1cade626-b76d-40c5-9e5a-101cf2a5e412

Categories