有没人遇到过拖动GROUPBOX时,GROUPBOX中的东西会有拖影?
给GROUPBOX加了个方法,拖动的时候触发GROUPBOX.LEFT和GROUPBOX.TOP使groupbox移动,但是发现GROUPBOX里面的控件移动的时候有拖影而且很厉害,于是在移动语句下加入了groupbox.refresh(),之后groupbox里的控件的拖影没那么严重了,但是还是会感觉一跳一跳的。感觉很不好,请问大家有没有办法解决这个问题?
另外我也已经在GROUPBOX中加入了
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.Selectable, true);
并且如果GROUPBOX中没有其他控件时拖动都很正常。不知道会不会是刷新GROUPBOX和里面的控件的时间不一致的关系~~~有人碰到过这种情况吗???
public class DragControlClass
{
//待拖动的控件
private Control m_Control;
//鼠标按下时的x,y坐标
private int m_X;
private int m_Y;
public DragControlClass(Control control)
{
m_Control = control;
m_Control.MouseDown += new MouseEventHandler(control_MouseDown);
m_Control.MouseMove += new MouseEventHandler(contro_MouseMove);
}
private void control_MouseDown(object sender, MouseEventArgs e)
{
m_X = e.X;
m_Y = e.Y;
}
private void contro_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int x = e.X - m_X;
int y = e.Y - m_Y;
this.m_Control.Left += x;
this.m_Control.Top += y;
}
m_Control.Refresh();
}