I think there is some silly mistake that I'm making...can anyone get this program to work??
My form has 2 panels. One has a TreeView and the other panel has a TabControl with one TabPage. This I call as OuterTabControl and OuterTabPage. The OuterTabPage has another TabControl with one TabPage with I call as InnerTabControl and InnerTabPage.
Now I want to drag and drop the node data of treeview onto the InnerTabPage.
The data is just String and I want it to get displaying on the TabPage at the point where I drop.
I have attached the code.
Some C# GUI guru please help.
i think u will need following things to be changed herez the code,
-------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
String str1 = "Child 1 data I want to drag and drop";
String str2 = "Child 2 data I want to drag and drop";
this.treeView1.Nodes[0].Nodes[0].Tag = str1;
this.treeView1.Nodes[0].Nodes[1].Tag = str2;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.treeView1 = new System.Windows.Forms.TreeView();
this.panel2 = new System.Windows.Forms.Panel();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.OuterTabPage = new System.Windows.Forms.TabPage();
this.tabControl2 = new System.Windows.Forms.TabControl();
this.InnerTabPage = new System.Windows.Forms.TabPage();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.tabControl1.SuspendLayout();
this.OuterTabPage.SuspendLayout();
this.tabControl2.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.treeView1});
this.panel1.Location = new System.Drawing.Point(8, 8);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 296);
this.panel1.TabIndex = 0;
//
// treeView1
//
this.treeView1.ImageIndex = -1;
this.treeView1.Location = new System.Drawing.Point(16, 32);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Parent", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Child 1"),
new System.Windows.Forms.TreeNode("Child 2")})});
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(152, 200);
this.treeView1.TabIndex = 1;
this.treeView1.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView1_ItemDrag);
//
// panel2
//
this.panel2.AllowDrop = true;
this.panel2.BackColor = System.Drawing.Color.White;
this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.tabControl1});
this.panel2.Location = new System.Drawing.Point(216, 8);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(248, 296);
this.panel2.TabIndex = 1;
//
// tabControl1
//
this.tabControl1.AllowDrop = true;
this.tabControl1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.OuterTabPage});
this.tabControl1.Location = new System.Drawing.Point(8, 8);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(232, 280);
this.tabControl1.TabIndex = 0;
//
// OuterTabPage
//
this.OuterTabPage.AllowDrop = true;
this.OuterTabPage.Controls.AddRange(new System.Windows.Forms.Control[] {
this.tabControl2});
this.OuterTabPage.Location = new System.Drawing.Point(4, 22);
this.OuterTabPage.Name = "OuterTabPage";
this.OuterTabPage.Size = new System.Drawing.Size(224, 254);
this.OuterTabPage.TabIndex = 0;
this.OuterTabPage.Text = "TabPage of Outer TabControl";
//
// tabControl2
//
this.tabControl2.Alignment = System.Windows.Forms.TabAlignment.Bottom;
this.tabControl2.AllowDrop = true;
this.tabControl2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.InnerTabPage});
this.tabControl2.Location = new System.Drawing.Point(8, 8);
this.tabControl2.Name = "tabControl2";
this.tabControl2.SelectedIndex = 0;
this.tabControl2.Size = new System.Drawing.Size(200, 240);
this.tabControl2.TabIndex = 0;
//
// InnerTabPage
//
this.InnerTabPage.AllowDrop = true;
this.InnerTabPage.Location = new System.Drawing.Point(4, 4);
this.InnerTabPage.Name = "InnerTabPage";
this.InnerTabPage.Size = new System.Drawing.Size(192, 214);
this.InnerTabPage.TabIndex = 0;
this.InnerTabPage.Text = "TabPage of Inner TabControl";
this.InnerTabPage.DragEnter += new System.Windows.Forms.DragEventHandler(this.InnerTabPage_DragEnter);
this.InnerTabPage.Paint += new System.Windows.Forms.PaintEventHandler(this.tabPageFlowView_Paint);
this.InnerTabPage.DragDrop += new System.Windows.Forms.DragEventHandler(this.tabPageFlowView_DragDrop);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(472, 310);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.panel2,
this.panel1});
this.Name = "Form1";
this.Text = "Drag Drop testing";
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.OuterTabPage.ResumeLayout(false);
this.tabControl2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
no, I mean associate my own custom icon with the dragging. So when I start dragging from the TreeView my own icon should be associated with the mouse cursor and not the slashed circle.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.