C#之放入透明背景字体(label标签的透明设置) |
您所在的位置:网站首页 › 透明底文字 › C#之放入透明背景字体(label标签的透明设置) |
如果想使用Winform仅仅把字体放入控件或者图片上要怎么办? 问题? 解决结果: 两种办法? 1、label标签设置透明度,但是不是单单设置一下Transparent你就可以达到你的目的了,你还需要设置一下label的Parent并且指定她相对于父窗体的Location才行。 2、使用Graphics类库画出来你的字,给个合适的定位点就可以了。 下面贴出测试代码: public Form1() { InitializeComponent(); //控件上的透明label label4.BackColor = Color.Transparent; label4.Parent = lbAnalogMeter1; lbAnalogMeter1.Controls.Add(label4); label4.Location = new Point(80, 150); //picture上的label label5.BackColor = Color.Transparent; label5.Parent = pictureBox1; label5.Location = new Point(80, 80); //pictureBox1.Controls.Add(label5); } private void Form1_Load(object sender, EventArgs e) { Bitmap bt = new Bitmap(pictureBox1.BackgroundImage); string myfont = "我是画笔画出的字"; Graphics g = Graphics.FromImage(bt); g.DrawString(myfont, new Font("宋体", 30), new SolidBrush(Color.Red), new PointF(10, 10)); pictureBox1.Image = bt; |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |