Make ListBox items have a different value than item text

前端 未结 5 1604
旧时难觅i
旧时难觅i 2020-12-08 21:18

I want a ListBox full of items. Although, each item should have a different value. So when the user selects an item and presses a button, a method will be calle

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 22:01

    items have a property called 'Tag', which you can use to store any information you want (hidden from the user)

    ListViewItem myItem = new ListViewItem();
    myItem.Text = "Users see this";
    myItem.Tag = "Users don't see this";
    

    (or set the appropriate properties in the property explorer)

提交回复
热议问题