65.9K
CodeProject is changing. Read more.
Home

TagItem

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.80/5 (2 votes)

Sep 3, 2004

viewsIcon

25413

downloadIcon

376

How to fill in Text and ID into same ListBox item or "Where is my ItemData".

Introduction

First ListBox control use in .NET was very confusing for me. Like, I am sure many of you, I used ItemData to fill in ID of somekind. But there is no ItemData in Kansas anymore so "Dorothy" had to find another solution.

It took me some time to see that new "Items.Add" formula takes Object as argument. From there, everything was downhill.

By using Text and ID as an argument for constructor, this class can be successfully used to retrieve/change same information later. One additional Object argument is added for "just in case" situations.

Since talk is cheap, try the sample.