删除C#中没有透明色的背景PictureBox [英] remove background PictureBox in C# without transparent color

查看:115
本文介绍了删除C#中没有透明色的背景PictureBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有带透明控制的pictureBox控件。我用拖动和移动它移动它滴鼠标。

但它有闪烁。我用这个代码移动





 control.MouseMove + = 委托 object  sender,MouseEventArgs e)
{
if (拖动)
{
如果(方向!=方向。垂直)
container.Left = Math.Max( 0 ,eX + container.Left - DragStart.X);
if (direction!= Direction.Horizo​​ntal)
container.Top = Math.Max( 0 ,eY + container.Top - DragStart.Y);
}
}





我尝试了一些方法来解决它,例如

 Application.DoEvents()





 g.SmoothingMode = System .Drawing.Drawing2D.SmoothingMode.AntiAlias 





但他们效率不高,我想知道是否有任何方式如pictureBox的更改区域为背景删除没有透明颜色的背面颜色?

感谢您的回复

解决方案

您好,



你应该尝试在你的代码中调用SuspendLayout和ResumeLayout:

 control.MouseMove + = 委托 object  sender,MouseEventArgs e)
{
if (拖动)
{
.SuspendLayout();
if (directio n!= Direction.Vertical)
container.Left = Math.Max( 0 ,e.X + container.Left - DragStart.X);
if (direction!= Direction.Horizo​​ntal)
container.Top = Math.Max( 0 ,eY + container.Top - DragStart.Y);
.ResumeLayout();
}
}


hi
I have pictureBox Control with transparent control . I move it with drag & drop mouse .
but it has flicker.I move with this code


control.MouseMove += delegate(object sender, MouseEventArgs e)
{
   if (Dragging)
   {
       if (direction != Direction.Vertical)
	   container.Left = Math.Max(0, e.X + container.Left - DragStart.X);
       if (direction != Direction.Horizontal)
	    container.Top = Math.Max(0, e.Y + container.Top - DragStart.Y);
   }
}



I try some method for solve it such as

Application.DoEvents()


Or

g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias



But they were not efficient , I want know is there any way such as change region of pictureBox to remove back color without Transparent color for background?
thanks for your replies

解决方案

Hello,

you should try to put a call to SuspendLayout and ResumeLayout in your code:

control.MouseMove += delegate(object sender, MouseEventArgs e)
{
   if (Dragging)
   {
       this.SuspendLayout();
       if (direction != Direction.Vertical)
	   container.Left = Math.Max(0, e.X + container.Left - DragStart.X);
       if (direction != Direction.Horizontal)
	    container.Top = Math.Max(0, e.Y + container.Top - DragStart.Y);
       this.ResumeLayout();
   }
}


这篇关于删除C#中没有透明色的背景PictureBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆