Get object information of selected listbox item

user6228552

I have objects in my list box that contain an instance of the BankAccount class (Balance, transfer, Withdraw methods) and Wallet class (name, birthday, etc.)
I need to view certain parts of information (like balance) about the selected list box object (lbAccounts).

Objects in Listbox:

DateTime birth = Convert.ToDateTime("01/01/1970");

Wallet account = new Wallet("Bob", "Smith", birth);
BankAccount account1 = new BankAccount(account);
account1.DepositFunds(5000);
BankAccount account2 = new BankAccount(account);
account2.DepositFunds(300);

//Adding accounts to listbox
lbAccounts.Items.Add(account1);
lbAccounts.Items.Add(account2);

QUESTION: How do I get the balance of a selected listbox object?

Jugal Panchal

You will get the object from selected item of list box.

BankAccount ba = lbAccounts.SelectedItem as BankAccount;

I hope it will help you.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Change background color of selected item in listbox

From Dev

Check if the selected item in a listbox contains specific characters

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

Get selected item from databound ListBox

From Dev

Get a List of the Selected Values in a ListBox

From Dev

Foreach selected item in Listbox?

From Dev

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

From Dev

ListBox.ContextMenu Get Selected Item via Command

From Dev

Bind DataGrid to ListBox selected item

From Dev

Multidata trigger condition for listbox to check if an item is selected

From Dev

ListBox: Item selected is not highlighted

From Dev

Get Selected Item from Windows Phone listbox in Hold event

From Dev

ListBox selected item refer to a variable

From Dev

Getting selected item from a listbox

From Dev

Add item to collection of selected item of listbox

From Dev

How can I get a listbox's selected item binded element?

From Dev

Get Selected Item ListBox WP8.1 C#

From Dev

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

From Dev

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

From Dev

get Values of one listbox item selected

From Dev

ListBox.ContextMenu Get Selected Item via Command

From Dev

How to get selected item of a listbox within a listbox

From Dev

Get object information of selected listbox item

From Dev

Listbox.ItemContainerStyle selected item

From Dev

Listbox binding get selected item value

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

ListBox get selected index?

Related Related

  1. 1

    Change background color of selected item in listbox

  2. 2

    Check if the selected item in a listbox contains specific characters

  3. 3

    How to get listbox selected item value

  4. 4

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

  5. 5

    Get selected item from databound ListBox

  6. 6

    Get a List of the Selected Values in a ListBox

  7. 7

    Foreach selected item in Listbox?

  8. 8

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

  9. 9

    ListBox.ContextMenu Get Selected Item via Command

  10. 10

    Bind DataGrid to ListBox selected item

  11. 11

    Multidata trigger condition for listbox to check if an item is selected

  12. 12

    ListBox: Item selected is not highlighted

  13. 13

    Get Selected Item from Windows Phone listbox in Hold event

  14. 14

    ListBox selected item refer to a variable

  15. 15

    Getting selected item from a listbox

  16. 16

    Add item to collection of selected item of listbox

  17. 17

    How can I get a listbox's selected item binded element?

  18. 18

    Get Selected Item ListBox WP8.1 C#

  19. 19

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

  20. 20

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

  21. 21

    get Values of one listbox item selected

  22. 22

    ListBox.ContextMenu Get Selected Item via Command

  23. 23

    How to get selected item of a listbox within a listbox

  24. 24

    Get object information of selected listbox item

  25. 25

    Listbox.ItemContainerStyle selected item

  26. 26

    Listbox binding get selected item value

  27. 27

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

  28. 28

    How to get particular property from item selected in ListBox

  29. 29

    ListBox get selected index?

HotTag

Archive