listbox with icons , C#

T

Thomas Adler

Hello,

I want to create a listbox with icons.

Icon1 --- Item1 ----comment01
Icon1 --- Item2 ----comment01
Icon1 --- Item3 ----comment01
Icon2 --- Item4 ----comment01
Icon1 --- Item5 ----comment01
Icon2 --- Item6 ----comment06
......
Icon2 --- ItemN ----comment0N

The listbox have 10 entries. After then, the scrollbar should be appears.
If Entries > 500 I want to delete the oldest item.

The icon is depend from the state. I need more than 2 icons.

Addtional I need a log file for all items entries.
Every day a new log file.

How can i make that?

Best regards Thomas
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You cannot do this with the stock Listbox, you have two options:
1- Implement your own control
2- Use a third party tool. I use Infragistics and they have a combobox
control that have this feature you want.
 
P

Peter Duniho

Hello,
Hi.

I want to create a listbox with icons.

You can override the DrawItem and related events to draw the icon as you
like. If you can use a ListView instance instead, then that offers the
various ImageList properties (LargeImageList, SmallImageList,
StateImageList) that you can use to easily assign specific icons to list
items.
Icon1 --- Item1 ----comment01
Icon1 --- Item2 ----comment01
Icon1 --- Item3 ----comment01
Icon2 --- Item4 ----comment01
Icon1 --- Item5 ----comment01
Icon2 --- Item6 ----comment06
.....
Icon2 --- ItemN ----comment0N

The listbox have 10 entries. After then, the scrollbar should be appears.
If Entries > 500 I want to delete the oldest item.

The scrollbar you can just enable. The removal of the oldest item you
will have to do yourself.
The icon is depend from the state. I need more than 2 icons.

See above.
Addtional I need a log file for all items entries.
Every day a new log file.

This is separate from the ListBox or ListView class. You'll have to write
some other code to write out the log file entries as they are added to the
ListBox or ListView.

Pete
 
T

Thomas Adler

Hello together,

thanks for the response.
The scrollbar you can just enable. The removal of the oldest item you
will have to do yourself.


See above.


This is separate from the ListBox or ListView class. You'll have to write
some other code to write out the log file entries as they are added to the
ListBox or ListView.
Have you a link or code example?
Maybe first, without icons. It is easier.

Thanks.

Regards Thomas
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Thomas Adler said:
Hello together,

thanks for the response.
Have you a link or code example?
Maybe first, without icons. It is easier.


I was looking into creating a owner drawing control (a listbox) a time ago.
These links helped me a lot
http://samples.gotdotnet.com/quickstart/howto/doc/WinForms/WinFormsOwnerDrawListBox.aspx
http://www.opennetcf.org/permalink2.aspx?guid=d88b1a1a-a866-4247-a0c8-94ab3c124f63

I was targeting the compact framework so I used more the second link.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top