WinForm自定义控件扩展
来源:互联网 发布:时时彩源码开奖器 编辑:程序博客网 时间:2024/06/10 14:50
using System;
using System.Drawing;
using System.Windows.Forms;
//msg=0x115 (WM_VSCROLL)
//msg=0x114 (WM_HSCROLL)
/// <summary>
/// CListView 的摘要说明。
/// </summary>
public class CListView : ListView
{
private TextBox m_tb;
public CListView()
{
m_tb = new TextBox();
m_tb.Multiline = true;
m_tb.Visible = false;
this.GridLines = true;
this.CheckBoxes = true;
this.FullRowSelect = true;
this.Controls.Add(m_tb);
}
private void EditItem(int Index)
{
if (this.SelectedItems.Count <= 0)
{
return;
}
ListViewItem item = this.SelectedItems[0];
Rectangle rect = item.Bounds;
Rectangle _rect = new Rectangle(rect.Right - this.Columns[Index].Width, rect.Top, this.Columns[Index].Width, rect.Height);
m_tb.Bounds = _rect;
m_tb.BringToFront();
m_tb.Text = item.SubItems[1].Text;
m_tb.Leave += new EventHandler(tb_Leave);
m_tb.TextChanged += new EventHandler(m_tb_TextChanged);
m_tb.Visible = true;
m_tb.Tag = item;
m_tb.Select();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.F2)
{
EditItem(1);
}
base.OnKeyDown(e);
}
protected override void OnSelectedIndexChanged(EventArgs e)
{
this.m_tb.Visible = false;
base.OnSelectedIndexChanged(e);
}
protected override void OnDoubleClick(EventArgs e)
{
Point tmpPoint = this.PointToClient(Cursor.Position);
ListViewItem item = this.GetItemAt(tmpPoint.X, tmpPoint.Y);
if (item != null)
{
if (tmpPoint.X > this.Columns[0].Width && tmpPoint.X < this.Width)
{
EditItem(1);
}
}
base.OnDoubleClick(e);
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x115 || m.Msg == 0x114)
{
this.m_tb.Visible = false;
}
base.WndProc(ref m);
}
private void tb_Leave(object sender, EventArgs e)
{
m_tb.TextChanged -= new EventHandler(m_tb_TextChanged);
(sender as TextBox).Visible = false;
}
private void m_tb_TextChanged(object sender, EventArgs e)
{
if ((sender as TextBox).Tag is ListViewItem)
{
(this.m_tb.Tag as ListViewItem).SubItems[1].Text = this.m_tb.Text;
}
}
}
- WinForm自定义控件扩展
- WinForm自定义控件–TextBox扩展
- WinForm自定义控件
- Winform之自定义控件
- 自定义winform分页控件
- Winform自定义控件实例
- 自定义winform分页控件
- Winform自定义控件实例
- winform制作自定义控件
- Winform自定义控件
- winform自定义控件
- WinForm自定义控件
- Winform自定义控件实例
- WinForm自定义控件
- winform自定义panel控件
- winform 创建自定义控件
- winform 自定义控件-按钮
- winform自定义控件
- 个人认为嵌入式驱动开发者所必须的几个能力
- Perl、PHP、ASP、JSP技术比较
- android2.1 Eclair 编译运行
- jsp调用Servlet,以及Servlet部署
- .NET清除页面缓存
- WinForm自定义控件扩展
- 用安装好的虚拟机制作CentOS光盘镜像
- Aion Quest: Go Back into the Frillneck Habitat
- ARM中的立即数
- HBO纪录片《中国的非自然灾害:四川的眼泪》获奥斯卡奖提名
- Class隐形类型转换的几种用法
- 关于使用IIRF2.0 重写 导致 Cookie 不能在其它页面使用的问题
- Delphi正则表达式使用方法(TPerlRegEx)
- Aion Quest: Go Back into the Frillneck Habitat