Override listbox.text

  • Thread starter Thread starter Soren-a
  • Start date Start date
S

Soren-a

Hi all

I am currently using a custom made listbox, which has some more
features than the normal Listbox. There is however one area where I
would very much like the normal listbox functionality back - the Text
method.

When I, in the custom listbox, use the following code:

CustonListbox Custlsb = new CustomListbox();
..
..
..
string test = Custlsb.Text;

and run the code, I get the following result: test = "";

If I run a similar code for a normal Listbox:

string test = listBox1.Text;

The result is: test = "THE SELECTED TEXT";


Does anyone know how I can override det CustomListbox's Text method,
so I can get the functionallity of the normal Listbox.Text method???

Thanks in advance.

Regards
Søren Augustesen
 
Have I something missed? Why you can't just use "override" modifier?

public override string Text
{
get
{
return SelectedItem != null ? GetItemText(SelectedItem) : "";
}
}

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
Back
Top