这样做:using System;
using System.Drawing;
using System.Windows.Forms;namespace ViewControl
{
/// <summary>
/// ButTextBox 的摘要说明。
/// </summary>
public class ButTextBox: System.Windows.Forms.TextBox
{
private Button m_Button;
private bool m_AllowShowButton;
public delegate void ClickButtonDelegate(object sender);
public event ClickButtonDelegate OnClickButton; public ButTextBox()
{
//
// TODO: 在此处添加构造函数逻辑
//
//this.SetStyle(ControlStyles.DoubleBuffer,true);
m_Button = new Button();
m_Button.Size = new Size(this.Height,this.Height-4);
m_Button.Location = new Point(this.Width - this.m_Button.Width-4,0);
m_Button.BackColor = System.Drawing.SystemColors.Control;
m_Button.Click +=new EventHandler(m_Button_Click);
m_Button.Cursor = Cursors.Default;
m_Button.Visible = m_AllowShowButton;
this.Controls.Add(m_Button);
} public bool AllowShowButton
{
get
{
return m_AllowShowButton;
}
set
{
m_AllowShowButton = value;
}
} protected override void OnEnter(EventArgs e)
{
this.m_Button.Visible = m_AllowShowButton;
base.OnEnter (e);
} protected override void OnLeave(EventArgs e)
{
this.m_Button.Visible = false;
base.OnLeave (e);
} private void m_Button_Click(object sender, EventArgs e)
{
if (OnClickButton!=null)
{
OnClickButton(this);
}
}
}
}
using System.Drawing;
using System.Windows.Forms;namespace ViewControl
{
/// <summary>
/// ButTextBox 的摘要说明。
/// </summary>
public class ButTextBox: System.Windows.Forms.TextBox
{
private Button m_Button;
private bool m_AllowShowButton;
public delegate void ClickButtonDelegate(object sender);
public event ClickButtonDelegate OnClickButton; public ButTextBox()
{
//
// TODO: 在此处添加构造函数逻辑
//
//this.SetStyle(ControlStyles.DoubleBuffer,true);
m_Button = new Button();
m_Button.Size = new Size(this.Height,this.Height-4);
m_Button.Location = new Point(this.Width - this.m_Button.Width-4,0);
m_Button.BackColor = System.Drawing.SystemColors.Control;
m_Button.Click +=new EventHandler(m_Button_Click);
m_Button.Cursor = Cursors.Default;
m_Button.Visible = m_AllowShowButton;
this.Controls.Add(m_Button);
} public bool AllowShowButton
{
get
{
return m_AllowShowButton;
}
set
{
m_AllowShowButton = value;
}
} protected override void OnEnter(EventArgs e)
{
this.m_Button.Visible = m_AllowShowButton;
base.OnEnter (e);
} protected override void OnLeave(EventArgs e)
{
this.m_Button.Visible = false;
base.OnLeave (e);
} private void m_Button_Click(object sender, EventArgs e)
{
if (OnClickButton!=null)
{
OnClickButton(this);
}
}
}
}
解决方案 »
- 菜鸟数据库连接问题
- 搜狗手写输入,获取点中的汉字
- C# 下,p=>p.toString()中,=>是干什么用的?
- 求一 正则表达式
- 发了8次帖也没解决的小问题.高手们来帮忙啊?
- 请问怎么在A窗口中生成B窗口,然后在B窗口按下BUTTON时,得到B窗口中TextBox的内容?
- C#拷贝文件夹代码有BUG,帮忙指教以下!!!!!!
- XP做sql server2000服务器,其他机器怎么访问不了!!
- 请高手看看错在哪里!
- 新手winform转wpf dev的DockLayoutManager透明度问题
- 那个函数是打印啊,有没有象php的print_r
- sql server数据表去除重复记录并增加一个流水号主键
我结帖吧。