How to show the numeric position from a selected item in a listbox in a label

watchEm

Sorry for the confusing title but here is my situation: When I select an item from a listbox I want a label showing that item's number. For example if I choose the fifth item in the listbox the label should show "Item number 5 is selected".

How do I do this?

Kinin Roza

This is simple. All you need to do to get the index of the selected item in the listbox is to use the SelectedIndex property which returns the zero-based index of the selected item. If you want a one-based index instead, just add 1 to the index.

int index = listBox.SelectedIndex;
label.Text = $"Item number {index + 1} is selected.";

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to show data from selected item in listbox wpf using mvvm?

From Dev

How to show Listbox selected item (Image) in an another Control with larger size

From Dev

How to automatically move the scroll bar on the listbox to show the selected item - VBA

From Dev

How to show detail of selected item in listbox with scrollbar using tkinter

From Dev

How to change Listbox item color from selected Item(object)?

From Dev

Getting selected item from a listbox

From Dev

How to get selected item of a listbox within a listbox

From Dev

Show textarea if selected item in listbox changes

From Dev

How to remove selected item from ListBox in windwos phone 8.1 Silverlight

From Dev

How to get an image to display in Picturbox from a Listbox selected item

From Dev

How to get particular property from item selected in ListBox

From Dev

How to bind a JavaFX Label to the selected item from a ListView

From Dev

Get selected item from databound ListBox

From Dev

Remove 3 rows from selected item in ListBox

From Dev

Remove selected item from listbox but also database

From Dev

how to change the background of the selected item in a listbox?

From Dev

How to get listbox selected item value

From Dev

how to change the background of the selected item in a listbox?

From Dev

Tkinter Listbox How to tell if an item is selected

From Dev

How to get the index of a selected item in listbox and add to listbox two with button?

From Dev

How to get the index of a selected item in listbox and add to listbox two with button?

From Dev

How to show/hide only one selected item from list

From Dev

Foreach selected item in Listbox?

From Dev

ListBox: Item selected is not highlighted

From Dev

How can i set label text from listbox item value? c#

From Dev

How to get label of selected item in managed bean

From Dev

PrimeNg/Angular: How to display the label of a selected item?

From Dev

How to show selected value of a UIPickerView according to label

From Dev

How to show selected value of a UIPickerView according to label

Related Related

  1. 1

    How to show data from selected item in listbox wpf using mvvm?

  2. 2

    How to show Listbox selected item (Image) in an another Control with larger size

  3. 3

    How to automatically move the scroll bar on the listbox to show the selected item - VBA

  4. 4

    How to show detail of selected item in listbox with scrollbar using tkinter

  5. 5

    How to change Listbox item color from selected Item(object)?

  6. 6

    Getting selected item from a listbox

  7. 7

    How to get selected item of a listbox within a listbox

  8. 8

    Show textarea if selected item in listbox changes

  9. 9

    How to remove selected item from ListBox in windwos phone 8.1 Silverlight

  10. 10

    How to get an image to display in Picturbox from a Listbox selected item

  11. 11

    How to get particular property from item selected in ListBox

  12. 12

    How to bind a JavaFX Label to the selected item from a ListView

  13. 13

    Get selected item from databound ListBox

  14. 14

    Remove 3 rows from selected item in ListBox

  15. 15

    Remove selected item from listbox but also database

  16. 16

    how to change the background of the selected item in a listbox?

  17. 17

    How to get listbox selected item value

  18. 18

    how to change the background of the selected item in a listbox?

  19. 19

    Tkinter Listbox How to tell if an item is selected

  20. 20

    How to get the index of a selected item in listbox and add to listbox two with button?

  21. 21

    How to get the index of a selected item in listbox and add to listbox two with button?

  22. 22

    How to show/hide only one selected item from list

  23. 23

    Foreach selected item in Listbox?

  24. 24

    ListBox: Item selected is not highlighted

  25. 25

    How can i set label text from listbox item value? c#

  26. 26

    How to get label of selected item in managed bean

  27. 27

    PrimeNg/Angular: How to display the label of a selected item?

  28. 28

    How to show selected value of a UIPickerView according to label

  29. 29

    How to show selected value of a UIPickerView according to label

HotTag

Archive