Peter
Peter

Reputation: 76

C# Images in a listbox

I have created a stock market simulation program, the prices fluctuate every few seconds and I track if they've gone up or down. I want to display a green up arrow if the price goes up and a red down arrow if the price goes down.

The prices are stored in an array which populates a listbox using

stockListBox.Items.AddRange( stockValues );

Could I create an object such as

Object [] stockObject = { stockValue , outputIcon };

and populate my list box with these objects? Where stockValue would be the value of my stock and outputIcon would be the green arrow or the red arrow

Upvotes: 0

Views: 82

Answers (2)

Nejc Galof
Nejc Galof

Reputation: 2614

If icons is good enough, you can use listview. The Windows Forms ListView control can display icons from three image lists. Here is idea

Here is exemple how can you use instead of ListBox: DataGridView or ListView.

Upvotes: 1

NtFreX
NtFreX

Reputation: 11357

The Windows Forms Listbox Control doesn't support other types then string. If you don't want to go for external Libraries I recomend to create a UserControl.

Upvotes: 2

Related Questions