不想做复合控件,想在文本框里加个按钮
来源:互联网 发布:99乘法表js代码 编辑:程序博客网 时间:2024/03/29 08:24
我自己的想法是这样子。
控件上有一个属性设置为是的时候,当我在选定文本框为输入焦点的时候,里面最右边能显示一个可以有单击事件的小按钮。如果文本框失去焦点则按钮消失,同时单击事件不被激发。
如果控件的这个属性设置为否,则与普通文本框没有区别。
我自己做了一个,但是它总是不能显示出来那个按钮。
mark
LG
不不是把??
我怎么觉得好容易啊
关注
UP
谢谢各位捧场。
这样做:
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);
}
}
}
}
支持楼上的
谢谢hbxtlhx(下着春雨的天)
我结帖吧。
楼上的楼上正确
控件上有一个属性设置为是的时候,当我在选定文本框为输入焦点的时候,里面最右边能显示一个可以有单击事件的小按钮。如果文本框失去焦点则按钮消失,同时单击事件不被激发。
如果控件的这个属性设置为否,则与普通文本框没有区别。
我自己做了一个,但是它总是不能显示出来那个按钮。
1楼
mark
2楼
LG
3楼
不不是把??
我怎么觉得好容易啊
4楼
关注
5楼
UP
6楼
谢谢各位捧场。
7楼
这样做:
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);
}
}
}
}
8楼
支持楼上的
9楼
谢谢hbxtlhx(下着春雨的天)
我结帖吧。
10楼
楼上的楼上正确
- 不想做复合控件,想在文本框里加个按钮
- 在SVG图里加按钮
- 在 普通的文本框 里加入图片背景
- ext6.2如何在grid表格列里加button按钮
- 在C#.net中做页面上传的程序。用Dhtml的控件:(创建文件上载控件,该控件带有一个文本框和一个浏览按钮。)和类HtmlInputFile的两种方法
- 在鼠标右键菜单里加入注册/卸载控件选项
- 在Codejock工具条里加入控件的方法
- 使用文本框+按钮+awt,做加法器
- 如果想做......如果不想做......
- (CEGUI)如何创建控件 ------按钮和文本框
- 在anyView里加badgeValue.
- 不想做研发,换个方向还是继续坚持?
- 文本框提示~ 做个备注吧~
- gtk做个按钮界面
- 让文本框和按钮在同一水平线上
- 不想做开发了,想测试
- php学习,不想在windows平台下做
- UITableViewCell里加了个UISwitch
- 感受统一通信:思科员工的一天
- JComponent Class
- 一些界面标准规范(来自因特网)
- rtx客户无法离线接收文件
- UTF-8和unicode终极解答
- 不想做复合控件,想在文本框里加个按钮
- UNIX系统管理技术手册(第三版)
- C++各大名库宝典
- 硬盘的损伤与工作原理
- 试图在没有边框的文本框下划一条线可是有问题
- sql日期函数
- 博达路由器配置外网IP和默认路由
- 使用DataBinder.Eval绑定DataSource
- Spring事务配置上去后出现如下报错:java.lang.ClassCastException: $Proxy1解决