如何在PictureBox上透明的显示文字
2015-01-22 20:18
1011 查看
利用c#的GDI+技术,PictureBox.CreateGraphics()绘图,利用g.DrawString写文字。
利用this.Invalidate()刷新Form窗体,或者利用PictureBox.Invalidate()刷新PictureBox.。
范例代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CCDTest
{
public partial class Form1 : Form
{
string filename;
//Label lblResult;
public Form1()
{
InitializeComponent();
filename = Application.StartupPath + "";
}
private void Form1_Load(object sender, EventArgs e)
{
pbCCD.Load(filename);
}
private void pbCCD_MouseDown(object sender, MouseEventArgs e)
{
PointF pf = e.Location;
using (Graphics g = pbCCD.CreateGraphics())
{
Console.WriteLine("Beg MyDraw....");
Font f = new Font("Arial", 12);
g.DrawString("Hello!", f, Brushes.Violet, pf);
Console.WriteLine("End MyDraw.....");
}
}
private void pbCCD_MouseUp(object sender, MouseEventArgs e)
{
pbCCD.Invalidate();
}
}
}
利用this.Invalidate()刷新Form窗体,或者利用PictureBox.Invalidate()刷新PictureBox.。
范例代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace CCDTest
{
public partial class Form1 : Form
{
string filename;
//Label lblResult;
public Form1()
{
InitializeComponent();
filename = Application.StartupPath + "";
}
private void Form1_Load(object sender, EventArgs e)
{
pbCCD.Load(filename);
}
private void pbCCD_MouseDown(object sender, MouseEventArgs e)
{
PointF pf = e.Location;
using (Graphics g = pbCCD.CreateGraphics())
{
Console.WriteLine("Beg MyDraw....");
Font f = new Font("Arial", 12);
g.DrawString("Hello!", f, Brushes.Violet, pf);
Console.WriteLine("End MyDraw.....");
}
}
private void pbCCD_MouseUp(object sender, MouseEventArgs e)
{
pbCCD.Invalidate();
}
}
}
相关文章推荐
- 如何在PictureBox上透明的显示文字1(利用控件技术)
- 如何实现文字加透明背景显示在一张图片的底部的效果
- 如何让STATIC控件背景透明,只显示文字。其它控件也应该可以适用。
- 如何用C#显示竖排文字?
- 如何将pictureBox里的图片保存到数据库,然后从数据读取显示
- 如何在指定矩形框内水平/垂直显示多行文字(修订)
- 如何用C#显示竖排文字?
- 如何定制日历控件显示的星期文字
- 图片上显示透明文字
- VC中如何把一串文字旋转90度显示
- 使用mmit进行移动开发,如何在一行同时显示图片和文字.
- 如何给显示文字加一层黑色边框
- 如何在ToolBar中显示文字和图标,自定义图标大小,并和MenuItem关联
- 如何使桌面图标文字透明
- [VB.NET]如何通过FileListBox在PictureBox显示图片!!!!
- 在PictureBox上显示文字(用label或textbox背景色会有问题吧)
- Visual Basic 2005——如何在DataGridView控件的储存格中同时显示出文字与图片
- 如何让一个方框栏内的文字滚动显示?
- 如何使用qtp检查网页中显示的文字颜色为指定的颜色
- Visual Basic 2005——如何在DataGridView控件的储存格中同时显示出文字与图片