我在Panel中加了好多控件,当程序运行起来后,如何设置能让我移动或者改变Panel内部控件的位置、大小,就像在设计的时候那样可以随意的用鼠标移动、改变大小,而不是通过输入数据改变~~~~就像设计时DesignMode=false时那样,那位高手指教一下!!多谢~
解决方案 »
- 这个循环进度条程序对吗?
- 求教:不完全固定格式Excel导入问题
- 如何解决asp.net中文件的上传和下载超过4M的问题,有着独到的见解,等待高手的解决!
- 散分2010第一分--MessageBox的事.
- cs结构的程序的发布问题?
- MessageBox提示窗口被盖住
- openSmtp发送邮件的问题(553 错误)
- SQLServer Reporting Service导出PDF乱码问题!
- 谁会编外挂?
- 请问怎么用c#在一个acess数据库中建立一个access表,并且把一个已经赋值的变量的值写到这个access表的某一列中...谢谢....急用!!!!
- 请帮忙看一下我在vb转换为c#时遇到的一点问题
- 关于textbox运用的问题
这三个事件里面写代码就行了。很简单的。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;using System.Runtime.InteropServices; namespace testRunningDrag
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
[DllImport("user32.dll")]
private static extern int ReleaseCapture(); private void pic1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(pic1.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
}
}
http://panjiwen.cnblogs.com/archive/2005/10/archive/2005/10/10/251689.htmlps:实际微软也提供了DesignHost方面的demo,有两个版本net1.1和net2.0的(记不得名字了,自己找一下把)
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;using System.Runtime.InteropServices; namespace testRunningDrag
{
public partial class Form1 : Form
{
bool AreaChange = false;
Control moveCtrl; public Form1()
{
InitializeComponent();
} public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
[DllImport("user32.dll")]
private static extern int ReleaseCapture(); private void pic1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(pic1.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
} private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (this.AreaChange == true)
{
moveCtrl.Width = e.X-pic1.Left;
moveCtrl.Height = e.Y-pic1.Top;
}
} private void Form1_MouseDown(object sender, MouseEventArgs e)
{
//label1.Text = string.Format("{0},{1} {2},{3}", e.X.ToString(), e.Y.ToString(), pic1.Left + pic1.Width, pic1.Top + pic1.Height);
if (e.X - pic1.Left - pic1.Width < 10 && e.Y - pic1.Top - pic1.Height < 10)
{
AreaChange = true;
moveCtrl = pic1;
}
} private void Form1_MouseUp(object sender, MouseEventArgs e)
{
AreaChange = false;
}
}
}
http://www.myfirm.cn/news/DotNetUserInterface/20080221013104408.html
这仅仅是实现拖动,这个应该没有问题,想实现可以动态改变大小~~~to 8F:
确实想要此种效果,但是看Demo发现其框架基本就是一个类似Vs的,用在我这好像大材小用~~不过确实很有用,得仔细研究一下~~我再考虑是否可以组合控制一下,在选择每个控件后,增加8个小Picturebox分布在Control周围,控制一下mouse显示,实现更改大小,不知道这样如何??不知道那位达人还有更好的办法??
我觉得这个问题肯定有很多人遇到过,比如设计打印模板时就需要动态更改设计变量的为止等等~~~