问题如下:做一个软件,软件启动后,在工作区,显示一些图标,这些图标可以自由托动,添加、删除是通过点击右键菜单实现,就像Windows的文件夹一样,并且双击后,可以打开相对应的软件界面(界面都是自己写的)。如果有源码例子(注:例子必须满足上面的要求)发过来,直接给满分。
绝不失言。请高手们,不吝赐教~~,分不够的话,可以再加

解决方案 »

  1.   

    ListView的图标,能向windows中文件夹里面的文件图标自由拖动,想拖哪,拖哪??
    好像不行吧??
      

  2.   

    ListView可以实现你的要求!具体怎么做你可以去查MSDN
      

  3.   

    to:wzd24(牧野) 我怎么在MSDN上找不到啊,你帮我找!谢谢
      

  4.   

    ListView的图标是不能想拖哪就拖哪的,
    不过其它的基本上可以满足楼主的要求,
    还可以搞个小图标,大图标,列表图标,等等...
    MSDN找就有现成的例子了
      

  5.   

    其实人家看重的就是自由托动,大家别往ListView方面想了,哎,想想其它的办法
      

  6.   

    我也是用ListView实现的,各种图标都可以用
      

  7.   

    用mousedown事件,确定所要拖动的对象,然后在mousemove事件里根据鼠标的坐标位差调整对象的具体位置,可以在formload的时候用foreach(Control ctl in this.Controls)来统一为对象生成右键操作事件,另写一个方法,参数为需移动的对象和鼠标偏移值,这样就能实现了。
      

  8.   

    //这是我写的一个报表设计的代码片段,可拖动生成的图形,主要用的是mousedown,mousemove,mouseup三个事件,可以参考一下。 private void panel1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    if (e.Button!=System.Windows.Forms.MouseButtons.Left)
    {
    return;
    }
    if (bt!=BoxType.None)
    {
    leftpoint=new Point(e.X,e.Y);
    newenter=true;
    num=-1;
    return;
    }
    if (num!=-1)
    {
    enter=true;
    movenum=num;
    }
    else if (panel1.Cursor==System.Windows.Forms.Cursors.SizeNESW||panel1.Cursor==System.Windows.Forms.Cursors.SizeNS||panel1.Cursor==System.Windows.Forms.Cursors.SizeNWSE||panel1.Cursor==System.Windows.Forms.Cursors.SizeWE)
    {
    enter=true;
    movenum=GetNum(sender,e);
    }

    }
    private void panel1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    try
    {
    #region 绑定菜单
    for (int i=0;i<ATB.Count;i++)
    {
    if ((ATB[i].Type==BoxType.TextBox)||(ATB[i].Type==BoxType.LineBox))
    {
    if (Math.Min(ATB[i].First.X,ATB[i].Second.X) <= e.X && e.X<= Math.Max(ATB[i].First.X,ATB[i].Second.X) && Math.Min(ATB[i].First.Y,ATB[i].Second.Y) <= e.Y && e.Y<= Math.Max(ATB[i].First.Y,ATB[i].Second.Y))
    {
    num=i;
    this.panel1.ContextMenu=this.contextMenu1;
    break;
    }
    else
    {
    num=-1;
    this.panel1.ContextMenu=null;
    }
    }
    else if (ATB[i].Type==BoxType.Line)
    {


    if (new Point(e.X,e.Y)==ATB[i].First||new Point(e.X,e.Y)==ATB[i].Second)
    {
    num=i;
    this.panel1.ContextMenu=this.contextMenu1;
    break;
    }
    else if(e.X!=ATB[i].First.X && e.X!=ATB[i].Second.X && Math.Min(ATB[i].First.X,ATB[i].Second.X)<=e.X && Math.Max(ATB[i].First.X,ATB[i].Second.X)>=e.X && Math.Min(ATB[i].First.Y,ATB[i].Second.Y)<=e.Y && Math.Max(ATB[i].First.Y,ATB[i].Second.Y)>=e.Y && Math.Abs((e.Y-ATB[i].First.Y)/(e.X-ATB[i].First.X)-(e.Y-ATB[i].Second.Y)/(e.X-ATB[i].Second.X))<=0.2)
    {
    num=i;
    this.panel1.ContextMenu=this.contextMenu1;
    break;
    }
    else
    {
    num=-1;
    this.panel1.ContextMenu=null;
    }
    }
    }

    #endregion
    #region 改变鼠标状态
    if (enter)
    goto MouseDrag;
    if (num>=0&&ATB[num].Selected)
    panel1.Cursor=System.Windows.Forms.Cursors.SizeAll;
    else
    panel1.Cursor=System.Windows.Forms.Cursors.Default;
    for (int i=0;i<ATB.Count;i++)
    {
    if (ATB[i].Selected&&ATB[i].Type==BoxType.Line)
    {
    for (int m=1;m<=2;m++)
    {
    if (isInclude(sender,e,ATB[i].MovePoint1(m),ATB[i].MovePoint2(m),BoxType.LineBox))
    {
    panel1.Cursor=System.Windows.Forms.Cursors.SizeWE;
    if (m==1)
    dg=Drag.First;
    else
    dg=Drag.Second;
    break;
    }
    }
    }
    else if (ATB[i].Selected&&(ATB[i].Type==BoxType.LineBox || ATB[i].Type==BoxType.TextBox))
    {
    for (int m=1;m<=8;m++)
    {
    if (isInclude(sender,e,ATB[i].MovePoint1(m),ATB[i].MovePoint2(m),BoxType.LineBox)==true && (m==1 || m==5))
    {
    panel1.Cursor=System.Windows.Forms.Cursors.SizeNWSE;
    if (m==1)
    dg=Drag.First;
    else
    dg=Drag.Second;
    break;
    }
    else if (isInclude(sender,e,ATB[i].MovePoint1(m),ATB[i].MovePoint2(m),BoxType.LineBox)==true && (m==2 || m==6))
    {
    panel1.Cursor=System.Windows.Forms.Cursors.SizeNS;
    if (m==2)
    dg=Drag.First;
    else
    dg=Drag.Second;
    break;
    }
    else if (isInclude(sender,e,ATB[i].MovePoint1(m),ATB[i].MovePoint2(m),BoxType.LineBox)==true && (m==3 || m==7))
    {
    panel1.Cursor=System.Windows.Forms.Cursors.SizeNESW;
    if (m==3)
    dg=Drag.First;
    else
    dg=Drag.Second;
    break;
    }
    else if (isInclude(sender,e,ATB[i].MovePoint1(m),ATB[i].MovePoint2(m),BoxType.LineBox)==true && (m==4 || m==8))
    {
    panel1.Cursor=System.Windows.Forms.Cursors.SizeWE;
    if (m==4)
    dg=Drag.First;
    else
    dg=Drag.Second;
    break;
    }
    } }
    }

    #endregion
    #region 对象移动
    MouseDrag:
    if (enter&&movenum!=-1&&ATB[movenum].Selected && (ATB[movenum].Type==BoxType.LineBox || ATB[movenum].Type==BoxType.TextBox))
    {
    if (panel1.Cursor==System.Windows.Forms.Cursors.SizeAll)
    {         

    int x=ATB[movenum].Second.X-ATB[movenum].First.X;
    int y=ATB[movenum].Second.Y-ATB[movenum].First.Y;
    ATB[movenum].FirstSet(e.X-x/2,e.Y-y/2);
    ATB[movenum].SecondSet(ATB[movenum].First.X+x,ATB[movenum].First.Y+y);
    panel1.Refresh();
    }
    else if (panel1.Cursor==System.Windows.Forms.Cursors.SizeNWSE)
    {
    if (dg==Drag.First)
    {
    ATB[movenum].FirstSet(e.X,e.Y);
    panel1.Refresh();
    }
    else
    {
    ATB[movenum].SecondSet(e.X,e.Y);
    panel1.Refresh();
    }
    }
    else if (panel1.Cursor==System.Windows.Forms.Cursors.SizeNS)
    {
    if (dg==Drag.First)
    {
    ATB[movenum].FirstSet(ATB[movenum].First.X,e.Y);
    panel1.Refresh();
    }
    else
    {
    ATB[movenum].SecondSet(ATB[movenum].Second.X,e.Y);
    panel1.Refresh();
    }
    }
    else if (panel1.Cursor==System.Windows.Forms.Cursors.SizeNESW)
    {
    if (dg==Drag.First)
    {
    ATB[movenum].FirstSet(ATB[movenum].First.X,e.Y);
    ATB[movenum].SecondSet(e.X,ATB[movenum].Second.Y);
    panel1.Refresh();
    }
    else
    {
    ATB[movenum].FirstSet(e.X,ATB[movenum].First.Y);
    ATB[movenum].SecondSet(ATB[movenum].Second.X,e.Y);
    panel1.Refresh();
    }
    }
    else if (panel1.Cursor==System.Windows.Forms.Cursors.SizeWE)
    {
    if (dg==Drag.First)
    {
    ATB[movenum].SecondSet(e.X,ATB[movenum].Second.Y);
    panel1.Refresh();
    }
    else
    {
    ATB[movenum].FirstSet(e.X,ATB[movenum].First.Y);
    panel1.Refresh();
    }

    }
    }
    else if (enter&&ATB[movenum].Selected && ATB[movenum].Type==BoxType.Line)
    {
    if (panel1.Cursor==System.Windows.Forms.Cursors.SizeWE)
    {
    if (dg==Drag.First)
    {
    ATB[movenum].FirstSet(e.X,e.Y);
    panel1.Refresh();
    }
    else
    {
    ATB[movenum].SecondSet(e.X,e.Y);
    panel1.Refresh();
    }
    }
    else if (panel1.Cursor==System.Windows.Forms.Cursors.SizeAll)
    {         
    int x=ATB[movenum].Second.X-ATB[movenum].First.X;
    int y=ATB[movenum].Second.Y-ATB[movenum].First.Y;
    ATB[movenum].FirstSet(e.X-x/2,e.Y-y/2);
    ATB[movenum].SecondSet(ATB[movenum].First.X+x,ATB[movenum].First.Y+y);
    panel1.Refresh();
    }
    }
    #endregion
    }
    catch(Exception eee)
    {
    return;
    }
    }
    private void panel1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    if (e.Button!=System.Windows.Forms.MouseButtons.Left)
    {
    return;
    }
    rightpoint=new Point(e.X,e.Y);
    ATB.AddTextBox(leftpoint,rightpoint,bt);
    if(bt==BoxType.TextBox)
    {
    write=true;
    writebind=ATB.Count-1;
    this.richTextBox1.Text="";
    this.richTextBox1.Left=ATB[writebind].First.X;
    this.richTextBox1.Top=ATB[writebind].First.Y;
    this.richTextBox1.Width=ATB[writebind].Width+2;
    this.richTextBox1.Height=ATB[writebind].Height+2;
    this.richTextBox1.Visible=true;
    this.richTextBox1.Focus();
    }
    if(bt!=BoxType.None)
    {
    newenter=false;
    bt=BoxType.None;
    c1Command6_Click(null,null);
    this.panel1.Refresh();
    }
    if(enter)
    {
    enter=false;
    panel1.Cursor=System.Windows.Forms.Cursors.Default;
    movenum=-1;
    }
    }
      

  9.   


    TO:alldj(灵山妖姬),能不能把你做的那个东西,全发给我.
     我只是用来学习!非常感谢。
    E-Mail: [email protected]