Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2004, 05:27 AM
Authorized User
 
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default A ListBox problem

Hello!

when I add a new item to my ListBox ,I want to choose a new color for
it(different color from other items).

Can I make it? or is there any method I can distingush some items from
other items except by selecting them.

Or to I have rewrite the ListBox ,to make it have this function.

waiting for help

 
Old June 9th, 2004, 07:58 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It is my understanding that the <option> HTML element cannot have a color specified. The <select> element can, but that affects the entire select box not just particular elements. This is a limitation of HTML.
 
Old June 9th, 2004, 08:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Is this what you are looking for?

http://www.c-sharpcorner.com/Code/20...llDropDown.asp

Brian
 
Old June 10th, 2004, 01:55 AM
Authorized User
 
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks
but what about ListBox in window form,
can i make it in window application not web application?


 
Old June 10th, 2004, 07:39 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Sorry for the confusion, you never specified what type of application you are building.
 
Old June 12th, 2004, 03:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

if u need to have a list of colors to select why dont u use ColorDialog?! It was only a guess & suggestion.

Always:),
Hovik Melkomian.
 
Old June 15th, 2004, 06:45 PM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could make the ListBox.DrawMode = DrawMode.OwnerDrawFixed. Then you need to write an event handler for the ListBox.DrawItem event.

You can use the args parameter of the event to draw the background and focus rectangle of the item. You should find it quite easy to change the font colour.

There's a good example in the help documentation.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox Problem Brendan Bartley Access 4 November 26th, 2007 01:34 PM
ListBox problem aliirfan84 ASP.NET 2.0 Professional 5 May 28th, 2007 08:39 AM
listbox problem faizee36 Access VBA 4 April 27th, 2006 09:58 AM
ListBox Problem spacy ASP.NET 1.x and 2.0 Application Design 2 October 18th, 2004 05:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.