[英]Customize Item.Clear() of the CheckedListBox
I am looking to customize Item.Clear() of the CheckedListBox and I have been working on this for some time but am unable to access the Clear Method to override it.我正在寻找自定义 CheckedListBox 的 Item.Clear() 并且我已经为此工作了一段时间,但无法访问 Clear 方法来覆盖它。 The below code returns no suitable Method found to override.下面的代码返回没有找到合适的方法来覆盖。
public partial class cLBEx : CheckedListBox
{
public cLBEx()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
}
public override void Clear()
{
}
}
Any assistance would be much appreciated任何帮助将不胜感激
Because my comment on the last answer was deleted with the post:因为我对最后一个答案的评论被帖子删除了:
Clear Method is Part of ListBox.ObjectCollection
that's why you cant override it in any subclassed CheckedListBox
or ListBox
Types. Clear 方法是ListBox.ObjectCollection
的一部分,这就是为什么您不能在任何子类CheckedListBox
或ListBox
类型中覆盖它的原因。 You have to subclass ListBox.ObjectCollection
and then Subclass CheckedListBox
to change the Type of the underlying Item Property.您必须对ListBox.ObjectCollection
进行子类化,然后对CheckedListBox
进行子类化才能更改基础项目属性的类型。
Edit, for a smarter and quicker way, you can use an Extensionmethod like编辑,为了更智能、更快捷的方式,您可以使用 Extensionmethod,如
public static void ClearCollection(this ListBox.ObjectCollection list) {
// do work!
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.