[.net] ComboBox 'checked'

Started by
2 comments, last by JPulham 18 years ago
I have a checkbox user control and have made a ComboBox based on the same code (partly). The problem occurs when I have:

if(Checked)
{
    //draw toggled
}
else if(!Checked)
{
    //don't draw toggled
}
The ComboBox class dosn't have Checked and I wasn't sure what the property was to say its been pressed ect. Does any one know it?
pushpork
Advertisement
Look at the Selected* properties (SelectedIndex, SelectedItem, SelectedValue, SelectedText).

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

If(CB.SelectedIndex!=-1)

or

If(CB.SelectedItem!=null)

these are the cases, when there is something (an item in the list) selected in the combobox.

I suggest creating a new control:

class myComboBox : ComboBox
{
Bool Checked
{
get
{
return CB.SelectedItem!=null;
}
}
}
"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin
Thanks... I'll add the Checked Property to my control now!
pushpork

This topic is closed to new replies.

Advertisement