我拉了两个picturebox,picturebox1、picturebox2 picturebox1放在picturebox2的前面(picturebox2被遮住了),现在我想让picturebox1的背景变透明,从而看到picturebox2的内容,结果用这样的方法:pictureBox1.BackColor = Color.Empty;          
pictureBox1.BringToFront();
把picturebox2被遮住的部分也透明掉了(直接透到了form1的背景)
有什么方法之透明掉picturebox1,能看到那被遮住的picturebox2的部分?效果是这样的(picturebox1还在picturebox2上面,透明掉了后,picturebox2被遮住的部分也能正常显示)求代码+解释

解决方案 »

  1.   

    游戏中不规则图片重叠效果,在c#窗体中用pixturebox完成~
      

  2.   

    没有怎么看懂意思
    你就是要让PictureBox1不遮住PictureBox2是吗,你把PictureBox1是放在PictureBox2上的,本来就不会遮住呀你设置透明这些东西做什么呀?
    把问题是说清楚些
      

  3.   

    解释摘自COde prject:

    hi
    can anyone help to solve my problem.
    i have two picture boxes one on top of other.the picture box behibd the top one shows live video from web cam . i want the picture box on top to be transparent so that i can view the video in the second picturebox through the transaprent one for c# application.
    thanks ramyaCheck out MSDN Library on "ControlStyles" flag and "SupportsTransparentBackColor" and "Opaque" style. By using these styles and providing a background color with an "alpha" value you can make it transparent. All you need is to play with the alpha level of the System.Drawing.Color structure.Bluehunter
    MSDN给出的方法,里面有c#例:
    Giving Your Control a Transparent Background
    http://msdn.microsoft.com/en-us/library/wk5b13s4(VS.71).aspx一个实现标签变成透明的例子:
    http://www.codeproject.com/KB/static/translabelcontrol.aspx
      

  4.   

    意思我picturebox里有图片,用imagelist透明掉了外边,做成了不规则的,但是当另一个不规则图片重叠时,上层的picturebox里的透明直接透到了form,把另一个不规则图片割掉了一大块,(痛苦!),没办法了,只能来问~或者谁有好方法让两个不规则图片重叠(且可以操作:移动、缩放、旋转),我换个方法也行!
      

  5.   

    pictureFlat.BackColor = Color.Transparent;?
    四楼!这样不行!
      

  6.   

    四楼:一个实现标签变成透明的例子: 
    http://www.codeproject.com/KB/static/translabelcontrol.aspx
    貌似把背景给绘了出来,但这太长了吧,有没有简单的方法?
      

  7.   

    你忘记加一句:
    SetStyle(ControlStyles.SupportsTransparentBackColor, True);
    但即便这样Picturebox是不能真真做到透明效果的,但能做到的只是假的透明。引用No it doesnt work. It only makes the picturebox's back color same as the background.But its not transparent in real sense.
    要真真实现,很麻烦的.但我也的确发现有人真的做到过:
    http://www.bobpowell.net/transcontrols.htm
      

  8.   

    还有个方法就是用flash,你说的那些功能在flash中做到比较简单,毕竟实现不规则图片不是C#的本职工作。然后把flash和C#结合起来就行。flash做界面,当有点击,移动和旋转什么的就传递值给C#执行相应功能。而且他们两者之间是可以交互的。
      

  9.   

    重载OnPaint方法:protected override void OnPaint(PaintEventArgs e) 
    pictureBox1.Invalidate(); 
    PictureBOX想要重叠透明。改用WPF