|
用了这个东西就可以在文本框里插入图片了!!!
不完全代码:- class TransparentRichTextBox : RichTextBox
- {
- override protected CreateParams CreateParams
- {
- get
- {
- CreateParams cp = base.CreateParams;
- cp.ExStyle |= 0x20;
- return cp;
- }
- }
- }//透明的文本框
- class mytextbox : Panel
- {
- private TransparentRichTextBox t = new TransparentRichTextBox();//一个文本框
- private string text { set; get; }
- /// <summary>
- /// 文本设置
- /// </summary>
- public string Content
- {
- set
- {
- this.text= value;
- base.Invalidate();
- }
- get
- {
- return text;
- }
- }
- public mytextbox()
- {
- this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);//双缓冲优化
- base.BackColor = Color.Transparent;//透明色
- }
- protected override void OnSizeChanged(EventArgs e)
- {
- t.Size = new Size(Width, Height);
- t.BorderStyle = BorderStyle.None;
- t.Text = text;
- t.Parent = this;
- this.Controls.Add(t);
- base.OnSizeChanged(e);
- }
- }
复制代码 主要就是自绘控件
F6过后………………慢慢享受吧!!! |
|