I'm trying to override Sort() method in my custom control. When my control contains ListBox and then I override Sort() method, everything works.
But when I want my ListBox (1) to be extended by another ListBox (2), that contains Sort() method, and then add that ListBox (1) to my UserControl, then it sorts too, but isn't using my Sort() method (seems like it doesn't see my Sort(), just normal Sort() from ListBox class).
My ListBox (2) contains code:
//...
public class MyListBox: ListBox
{
public MyListBox
{
this.Sorted = true;
}
// more methods
override protected void Sort()
{
// sorting code
}
}
//...
And my custom control looks like:
//...
public partial class MyControl: UserControl
{
public MyControl()
{
InitializeComponent(); // method in MyControl.Designer.cs (myListBox1 is declared in that class)
}
// more methods
public ListBox.ObjectCollection Item //that's because I want my control to behavior like ListBox instead of creating void AddItem(Object) method, etc...
{
get { return myListBox1.Items; }
}
}
so I think everything should work, but it doesn't... Any ideas?