C
C#15mo ago
Kyhro

❔ 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 ?
8 Replies
TheBoxyBear
TheBoxyBear15mo ago
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 🙂
Kyhro
Kyhro15mo ago
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
TheBoxyBear
TheBoxyBear15mo ago
So what is the expected result?
Kyhro
Kyhro15mo ago
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"
TheBoxyBear
TheBoxyBear15mo ago
how is addRecipe called?
Kyhro
Kyhro15mo ago
it's a chain triggered by clicking the button
TheBoxyBear
TheBoxyBear15mo ago
Hard to tell without the full code. Use breakpoints to check the values at runtime and see where's it's different than expected.
Accord
Accord15mo ago
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.