Create custom listbox - how?

  • Thread starter Thread starter James Radke
  • Start date Start date
J

James Radke

Hello,

I would like to create a windows form custom listbox which allows me to set
two new properties:

1.) Bound Field Name which contains a boolean flag. (named
ChangeBackgroundFlag)
2.) Background color to use when Highlight field is true (named
ChangeBackgroundColor)

The listbox should function as it is, except when the bound item has a true
ChangeBackGroundFlag, it should use ChangeBackground color as the background
color to be displayed for that item in the listbox.

If an item with a true ChangeBackgroundFlag is selected, it should use the
standard selected background color.

Can someone explain to me how I can go about creating this control? or
point me to some resources that could help? I am stumped on this one...

Thanks!

Jim
 
* "James Radke said:
I would like to create a windows form custom listbox which allows me to set
two new properties:

1.) Bound Field Name which contains a boolean flag. (named
ChangeBackgroundFlag)
2.) Background color to use when Highlight field is true (named
ChangeBackgroundColor)

The listbox should function as it is, except when the bound item has a true
ChangeBackGroundFlag, it should use ChangeBackground color as the background
color to be displayed for that item in the listbox.

If an item with a true ChangeBackgroundFlag is selected, it should use the
standard selected background color.

Can someone explain to me how I can go about creating this control? or
point me to some resources that could help? I am stumped on this one...

Create a control which inherits from 'System.Windows.Forms.ListBox' and
set its 'DrawMode' to 'OwnerDraw*'. Then have a look at the control's
'MeasureItem' and 'DrawItem' events.
 
Back
Top