473,385 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Create custom listbox - how?

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
Nov 20 '05 #1
1 2157
* "James Radke" <jr*****@wi.rr.com> scripsit:
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.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Stevens | last post by:
I'd already posted this in microsoft.public.dotnet.framework.windowsforms and microsoft.public.dotnet.framework.windowsforms.controls to no avail so apologies for the cross-posting. Hi, I'm...
22
by: James Cane | last post by:
Here's an interesting problem that someone might have an answer to... Some time ago, I wrote a set of utility classes which wrap up the custom row source function needed to add arbitrary items to...
4
by: Paradox | last post by:
Hey, I'm trying to figure out what situations call for the use of a derived form control such as: public class myListBox : System.Windows.Forms.ListBox and what situations call for the use...
1
by: Pat Moline | last post by:
Today, we have an informational dialog where the information is displayed in a RichText control. The only action for the user is to press the OK button to dismiss the dialog. My desire is...
0
by: Chris Newby | last post by:
I have a custom control that is essentially implemented as follows: ================================================ public class TestPanel : WebControl, INamingContainer { protected override...
1
by: Chris Newby | last post by:
I have a very basic custom control that exposes an ITemplate property and everything seems pretty straight forward so far. But, when I put other server controls intro the template section of my...
3
by: Jay Ruyle | last post by:
I'm trying to figure out a way to list several items in a listbox and let the user select any number of items in the listbox. I have tried to code in the items as bitwise items but all it stores...
2
by: SiddharthK | last post by:
Hi all, Im trying to build a custom control using Windows Control Library (C# project). I am using a textbox and a listbox for this purpose. I want to add new items to the listbox during the...
1
by: jasydnor | last post by:
Hi, New to the forums and have a question. I've only been developing for about five months now so I apologize if this seems oversimplistic....I am writing a program on an idea I had on a whim. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.