列表框控件所有者绘制问题(向列表框项添加编辑控件)
我正在为列表框使用所有者绘制变量样式(winforms 2.0) 当用户选择一个项目时,我想在该单元格中绘制一个编辑控件 这可行吗 不是下拉菜单,而是出现在单元格或项目中的实际编辑控件 如何 谢谢
I am using owner draw variable style for a listbox( winforms 2.0)
when a user selects an items I want to draw an edit control in that cell
Is that doable
not a drop down but an actual edit control appearing in the cell or item as it were
how
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在为 ListView 使用一些类似的东西。 方法是:
创建TextBox,添加到Controls数组中,并隐藏一个。
innerTextBox.Size = new Size(0, 0);
innerTextBox.Location = new Point(0, 0);
this.Controls.AddRange(new Control[] { this.innerTextBox });
innerTextBox.KeyPress += new KeyPressEventHandler(this.EditOver);
innerTextBox.LostFocus += new EventHandler(this.FocusOver);
innerTextBox.Hide();
innerTextBox.Text = "";
在 DoubleClick 事件上绑定自己的方法,在其中查找选定的项目并将值获取到 TextBox
this.DoubleClick += new EventHandler(this.EditableDoubleClick);
private void EditableDoubleClick(对象发送者,System.EventArgs e)
{
selectedItemText = selectedItem.ToString();
innerTextBox.Size = new Size(subItemRect.right - subItemRect.left, subItemRect.bottom - subItemRect.top);
innerTextBox.Location = new Point(subItemRect.left, subItemRect.top);
innerTextBox.Show();
innerTextBox.Text = selectedItemText;
}
当文本框中失去焦点时 - 将值设置回所选项目。
selectedItem = insideTextBox.Text;
I'm using some similar for ListView. Method is:
Create TextBox, add to Controls array, and hide one.
innerTextBox.Size = new Size(0, 0);
innerTextBox.Location = new Point(0, 0);
this.Controls.AddRange(new Control[] { this.innerTextBox });
innerTextBox.KeyPress += new KeyPressEventHandler(this.EditOver);
innerTextBox.LostFocus += new EventHandler(this.FocusOver);
innerTextBox.Hide();
innerTextBox.Text = "";
On DoubleClick event bind own method where find selected Item and get value to TextBox
this.DoubleClick += new EventHandler(this.EditableDoubleClick);
private void EditableDoubleClick(object sender, System.EventArgs e)
{
selectedItemText = selectedItem.ToString();
innerTextBox.Size = new Size(subItemRect.right - subItemRect.left, subItemRect.bottom - subItemRect.top);
innerTextBox.Location = new Point(subItemRect.left, subItemRect.top);
innerTextBox.Show();
innerTextBox.Text = selectedItemText;
}
On lost focus in TextBox - set value back into selected item.
selectedItem = innerTextBox.Text;