listview 给每一个item里面怎么添加一个button 啊 ?
就像reapter里面的模板列添加button 一样的效果,NND,winform N久没整过了,各位指教一下。
就像reapter里面的模板列添加button 一样的效果,NND,winform N久没整过了,各位指教一下。
解决方案 »
- C# SerialPort COM1 读数据
- winForm中子窗体如何恰好嵌入在父窗体的状态栏下
- 关于combobox小问题!
- C#&WinForm,当窗口FormBorderstyle=none的时候,最小化到任务栏时,点右键没有效果
- 邮件验证
- 已知远程主机的IP地址,如何通过程序取到该主机网卡的MAC地址。急!!!谢谢!!!!!
- 事件的名称存在字符串变量中,如何触发对应的事件
- 要换工作了,散分祈福
- 让我们大家一起来声讨TOP吧!支持被裁的同志们
- 用了几天c#,有些感想"C#中是区分大小写,老是要注意大小写,有些烦.不知C#是否可以和vb一样.
- 关于C#提示对话框
- C#Socket编程的问题,关到窗体显示的关闭的....
是不是问错了,WINFORM 我不熟悉,各位有什么说什么 我汗。
用DataGridView就可以啊
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;
}
}
}
http://www.codeproject.com/KB/list/EXListView.aspxhttp://www.codeproject.com/KB/list/ListViewEmbeddedControls.aspx