Reach usercontrol's child control's methods
-
Hi, I need to create a usercontrol containing a listbox and a scrollbar in order to be able to skin the scrollbar. Unfortunately, I have to recode all listbox's methods if I want my usercontrol to have the same behavior as a classical Listbox... :( Is there a better way to reach all the listbox's methods without recoding them all ? Thanks in advance, that'll be very usefull :)
-
Hi, I need to create a usercontrol containing a listbox and a scrollbar in order to be able to skin the scrollbar. Unfortunately, I have to recode all listbox's methods if I want my usercontrol to have the same behavior as a classical Listbox... :( Is there a better way to reach all the listbox's methods without recoding them all ? Thanks in advance, that'll be very usefull :)
-
Why would you want to do this in the first place? And why do you think you will have to recode all the ListBox's methods? Isn't that why OOP includes inheritance?
Don't think he can inherit - sound like he is encapsulating the Listbox and a Scrollbar, so he can't inherit directly from the ListBox. Which means he has to provide pass-through methods or expose the ListBox directly - which he doesn't want to do.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
-
Don't think he can inherit - sound like he is encapsulating the Listbox and a Scrollbar, so he can't inherit directly from the ListBox. Which means he has to provide pass-through methods or expose the ListBox directly - which he doesn't want to do.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
-
Hi, I need to create a usercontrol containing a listbox and a scrollbar in order to be able to skin the scrollbar. Unfortunately, I have to recode all listbox's methods if I want my usercontrol to have the same behavior as a classical Listbox... :( Is there a better way to reach all the listbox's methods without recoding them all ? Thanks in advance, that'll be very usefull :)
If you want to access events of listbox in usercontrol without extra effort, not possible. If you want to access properties of listbox, create a property in Userclass.
public ListBox listBox
{
get { return listBox1; }
}and you need to define all required events;
public event EventHandler ListBoxClick
{
add { listBox1.Click += value; }
remove { listBox1.Click -= value; }
}Tim Toady Bicarbonate
-
Hi, I need to create a usercontrol containing a listbox and a scrollbar in order to be able to skin the scrollbar. Unfortunately, I have to recode all listbox's methods if I want my usercontrol to have the same behavior as a classical Listbox... :( Is there a better way to reach all the listbox's methods without recoding them all ? Thanks in advance, that'll be very usefull :)
Learn WPF. This is EXACTLY what its intended for. ZERO C# to skin a control and its scrollbars.
-
Learn WPF. This is EXACTLY what its intended for. ZERO C# to skin a control and its scrollbars.