Construct the method as you have, accepting a ListControl
as the parameter. Like so....
public DoSomething(Lis tControl lc)
{
//now check the param for its type
if(lc is ListBox)
{
//create a listbox from the param and use it
ListBox lb = (ListBox)lc;
//TODO do stuff with listbox..
}
if(lc is ComboBox)
{
//create a combo from the param and use it...
ComboBox cb = (ComboBox)lc;
//TODO do stuff with combo...
}
What you are doing is checking the parameter
for the object type you are looking for by using
the 'is' keyword and then casting your param
over to that type in a new variable specifically
of that type.
Hope this helps
Guy
-----Original Message-----
Hi.
I'd like to pass as a parameter of class method
referenceto ListControl (ListBox or ComboBox).
Here is my call:
public DoSomething(Lis tControl lc){}
It's ok with that, but lc does not have methods like
lc.BeginUpdate ;
lc.EndUpdate
but ListBox and ComboBox does have such a methods.
I don't like two methods like
public DoSomething(Lis tBox lc){};
public DoSomething(Com boBox lc){};
Is there a way to do that in one method and have
abilitiesto use .BeginUpdate and .EndUpdate ?
.