❔ How to display a class property in a list box ?
I am working on a recipe book software for uni and I have troubles displaying a class property in a listbox. I have an array of classes and I need to display the name property of the class in a listbox. I figured something is wrong with my display() method since the values are correctly retrieved (I checked it with message box). Can anyone tell me what I am doing wrong here ?
![](https://utfs.io/f/0a44086b-6222-4873-ae1a-eb7966db3262-kimlji.jpg)
8 Replies
It's adding the value of showing and not Name
Also since the methods are only using the index to retrieve the recipe, you can change the parameters to take a single recipe instead and index the array inside the calls 🙂
sorry I forgot to add more context, basically the class display is supposed to be called after a name of recipe got input by the user, it's called from the method addRecipe located in the class Recipe
![](https://utfs.io/f/58bce04d-53e7-49a2-87f3-f30bdd780f7d-jlo1cb.jpg)
![](https://utfs.io/f/1e27ccf4-4ead-411b-90b0-ad1479ee6b6e-jlo1ca.jpg)
So what is the expected result?
to add the name property of the class Recipe to a listbox
this property is a string
and the class instance recipe is located in an array of class instances "recipes"
how is addRecipe called?
it's a chain triggered by clicking the button
![](https://utfs.io/f/cc3ddd9b-d44f-48c6-ba85-d920ff758ea0-jlo1cb.jpg)
![](https://utfs.io/f/d7755f4d-41f6-4566-bf7f-281bdb2b4cfb-jlo1ca.jpg)
Hard to tell without the full code. Use breakpoints to check the values at runtime and see where's it's different than expected.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.