using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 窗体透明度
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
Form1 frm = this;
frm.Opacity = (double)(trackBar1.Value) / 100;
}
private void Form1_Load(object sender, EventArgs e)
{
this.Opacity = (double)(trackBar1.Value)/100;
}
}
}
trackbar 的值 max :100 min 0
然后在程序时间代码中 ,将 trackbar的值转换为 double然后除以100,转换为 %比 ,就可以赋值给 Opacity了, 通过 Form1 frm=this 来获得当前窗口对象
程序代码及 效果图:
http://yunpan.cn/csJJf4txgc93M 提取码 86c6