怎样让listView控件的其中一列在点击的时候编程可编辑状态

2024-12-19 10:14:20
推荐回答(1个)
回答1:

private void listView1_DoubleClick(object sender, EventArgs e)
{
ListViewItem lvi=listView1.SelectedItems[0];
TextBox tb = new TextBox();
tb.LostFocus += new EventHandler(this.Text_Blur);
tb.Location =new Point(lvi.Bounds.Left,lvi.Bounds.Top);
listView1.Controls.Add(tb);
tb.Focus();
tb.Text = lvi.Text;
}
private void Text_Blur(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
ListViewItem lvi = listView1.SelectedItems[0];
lvi.Text = tb.Text;
tb.Parent.Controls.Remove(tb);
}