You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

108 lines
2.4 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace Stone.WinModule.MyControl
{
public partial class MySelectTextBox : UserControl
{
#region 属性
[CategoryAttribute(""), DescriptionAttribute("获取或设置控件显示的内容")]
public override string Text
{
get
{
return this.txtSelect.Text.Trim();
}
set
{
this.txtSelect.Text = value;
}
}
[CategoryAttribute(""), DescriptionAttribute("设置控件的只读属性")]
public bool ReadOnly
{
get
{
return this.txtSelect.ReadOnly;
}
set
{
this.txtSelect.ReadOnly = value;
}
}
#endregion
#region 方法
new public void Focus()
{
this.txtSelect.Focus();
}
public void SelectAll()
{
this.txtSelect.SelectAll();
}
#endregion
#region 界面调整
public MySelectTextBox()
{
InitializeComponent();
}
private void MySelectTextBox_Load(object sender, EventArgs e)
{
ControlAutoSize();
}
private void MySelectTextBox_Resize(object sender, EventArgs e)
{
ControlAutoSize();
}
private void ControlAutoSize()
{
this.txtSelect.Location = new Point(0, 0);
this.Height = this.txtSelect.Height;
this.btnSelect.Left = this.txtSelect.Width - this.btnSelect.Width - 1;
this.btnSelect.Top = this.txtSelect.Top-1;
this.txtSelect.Width = this.Width;
}
#endregion
#region 事件
//点击事件
public event EventHandler OnSelectClick;
private void btnSelect_Click(object sender, EventArgs e)
{
if (OnSelectClick != null)
{
OnSelectClick(this, e);
}
}
private void txtSelect_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
btnSelect_Click(this, e);
}
}
#endregion
}
}