pictureBox控件上放label或者pictureBox2时背景不透明的问题解决办法:
1、用panel控件代替pictureBox控件2、将子控件的背景设置成Transparent
窗体渐现
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
/// <summary> /// 显示窗体 /// </summary> private void ShowWin() { this.tsmiShowHide.Text = "隐藏"; this.SetWindowState(); this.Opacity = 0; // 打开窗口渐现效果 Timer tStart = new Timer(); tStart.Interval = 100; tStart.Tick += new EventHandler(tStart_Tick); tStart.Start(); }/// <summary>
/// 隐藏窗体 /// </summary> private void HideWin() { this.tsmiShowHide.Text = "显示"; // 关闭窗口渐现效果 Timer tClose = new Timer(); tClose.Interval = 100; tClose.Tick += new EventHandler(tClose_Tick); tClose.Start(); }/// <summary>
/// 关闭窗体渐现效果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void tClose_Tick(object sender, EventArgs e) { // 每一次执行透明度减少10% this.Opacity -= 0.1; if (this.Opacity <= 0) { ((Timer)sender).Stop(); } } /// <summary> /// 打开窗体渐现效果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void tStart_Tick(object sender, EventArgs e) { // 每一次执行透明度增加10% this.Opacity += 0.1; if (this.Opacity == 1) { ((Timer)sender).Stop(); this.Focus(); } }
vs2005里面给控件提供了DrawToBitmap函数
例如: // 保存窗体到图片 Bitmap formBitmap = new Bitmap( this .Width, this .Height); this .DrawToBitmap(formBitmap, new Rectangle( 0 , 0 , this .Width, this .Height)); formBitmap.Save( @" d:\form.bmp " , ImageFormat.Bmp); // 保存控件DataGridView到图片 Bitmap controlBitmap = new Bitmap( this .dataGridView1.Width, this .dataGridView1.Height); this .dataGridView1.DrawToBitmap(controlBitmap, new Rectangle( 0 , 0 , this .dataGridView1.Width, this .dataGridView1.Height)); controlBitmap.Save( @" d:\control.bmp " , ImageFormat.Bmp);