再次请教:是否能将一个RadioButton控件拖放到PANEL中?该如何实现? 能不能说清楚点,是把radiobutton移动到panel中去,还是在panel中重新生成一份副本了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 重新生成一个副本,,使用鼠标拖拽radionbutton,将它拉到一个Panel中去,原来的RadionButton控件还在原处,在拖拽过程中,鼠标的样式应该是Radionbutton 使用动态添加控件==================问题是怎样获得拖放的事件啊,我试了很多方法,就是不能拖动RadionButton 问题是你在什么情况下触发拖动事件,如果是鼠标的MouseDown的话(这个本来该是选择该radioButton的)?????? private int oldx,oldy;private int startx,starty;private bool flagMove;private void radioButton1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e){ if (e.Button==MouseButtons.Left) { radioButton1.Capture=true; oldx=radioButton1.Left; oldy=radioButton1.Top; startx=e.X; starty=e.Y; flagMove=true; }}private void radioButton1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e){ if (e.Button==MouseButtons.Left && flagMove) { radioButton1.Left+=e.X-startx; radioButton1.Top+=e.Y-starty; if (radioButton1.Left<panel1.Left+panel1.Width && radioButton1.Left>panel1.Left && radioButton1.Top<panel1.Top+panel1.Height && radioButton1.Top>panel1.Top) { add(); radioButton1.Left=oldx; radioButton1.Top=oldy; flagMove=false; } }}private void add(){ RadioButton r=new RadioButton(); r.Enabled=true; panel1.Controls.Add(r);}private void radioButton1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e){ radioButton1.Capture=false; flagMove=false;}我试验了一下,应该可以实现楼主的想法 看看这里,我看了例子,跟楼主要求差不多http://www.codeproject.com/cs/miscctrl/LANDragDrop.asp 偶滴亲神啊,这到底是什么问题啊~~~~(下载过程中的进度条问题) TreeView 怎么判断选中节点下,是否存在子节点 报表中就是没有数据,麻烦高手帮我看看。 求教c#角度的测量 请教一个关于文件写入的问题 C#如何修改文件的创建时间,修改时间,访问时间? gridControl 单元格换行的问题 日期对比的问题,如何对比记录中存储的日期是当天日期??? C# 可以在Panel中穿件winform么? 在CSDN的重庆朋友来这儿签个到 怪事?!Windows Form中的DataGrid,无法移除列中所有的TextBox?? .Net程序能不能做成数据库无关性
==================
问题是怎样获得拖放的事件啊,我试了很多方法,就是不能拖动RadionButton
private int startx,starty;
private bool flagMove;
private void radioButton1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button==MouseButtons.Left)
{
radioButton1.Capture=true;
oldx=radioButton1.Left;
oldy=radioButton1.Top;
startx=e.X;
starty=e.Y;
flagMove=true;
}
}private void radioButton1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button==MouseButtons.Left && flagMove)
{
radioButton1.Left+=e.X-startx;
radioButton1.Top+=e.Y-starty;
if (radioButton1.Left<panel1.Left+panel1.Width && radioButton1.Left>panel1.Left && radioButton1.Top<panel1.Top+panel1.Height && radioButton1.Top>panel1.Top)
{
add();
radioButton1.Left=oldx;
radioButton1.Top=oldy;
flagMove=false;
}
}
}private void add()
{
RadioButton r=new RadioButton();
r.Enabled=true;
panel1.Controls.Add(r);
}
private void radioButton1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
radioButton1.Capture=false;
flagMove=false;
}
我试验了一下,应该可以实现楼主的想法
http://www.codeproject.com/cs/miscctrl/LANDragDrop.asp