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.

109 lines
2.4 KiB

3 years ago
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
}
}