C
C#12mo ago
chronos

listbox display help !

Any idea why this listbox isnt working?
No description
No description
No description
31 Replies
chronos
chronosOP12mo ago
No description
chronos
chronosOP12mo ago
when i try to add an item from the list, it just displays this each item is tied to a location instead of the corresponding item it just says blaisefinalproject.item and only allows one to be added
Jimmacle
Jimmacle12mo ago
it is probably simply calling ToString on your object to determine what to display in the list so the quick and dirty fix would be to override ToString for your item to display what you want i would expect there to be a better way but i avoid winforms
chronos
chronosOP12mo ago
i also do not like winforms this is for a school assignment .. also thanks i’ll try that ❤️ ok@i feel a little silly how would i do that where do i put the .ToString
Jimmacle
Jimmacle12mo ago
you need to override that method in your Item class
chronos
chronosOP12mo ago
errr
Jimmacle
Jimmacle12mo ago
like
public override string ToString()
{
return ItemName;
}
public override string ToString()
{
return ItemName;
}
chronos
chronosOP12mo ago
oh yeah silly me i’ve done that before in this project already
chronos
chronosOP12mo ago
No description
chronos
chronosOP12mo ago
hmm
Jimmacle
Jimmacle12mo ago
why are you writing that?
chronos
chronosOP12mo ago
um to convert it to a string.. : P
Jimmacle
Jimmacle12mo ago
you don't need to
chronos
chronosOP12mo ago
well
Jimmacle
Jimmacle12mo ago
winforms is calling it itself
chronos
chronosOP12mo ago
it doesn’t work still.. WAIT ok it works kind of now it gets the correct item but i can only store one?
Jimmacle
Jimmacle12mo ago
store one where?
chronos
chronosOP12mo ago
No description
chronos
chronosOP12mo ago
when i try to add more items nothing happens
Jimmacle
Jimmacle12mo ago
if you update the list you need to tell winforms it updated somehow
chronos
chronosOP12mo ago
only the first is registered
Jimmacle
Jimmacle12mo ago
which is where my knowledge of winforms stops
chronos
chronosOP12mo ago
i shall look this up
Jimmacle
Jimmacle12mo ago
i don't know if winforms has data binding but that's what i'd use in other frameworks
chronos
chronosOP12mo ago
i think it’s just .Refresh ok nope anyone else know what’s up with this
chronos
chronosOP12mo ago
No description
chronos
chronosOP12mo ago
it just displays the first item i get and nothing else
chronos
chronosOP12mo ago
No description
chronos
chronosOP12mo ago
my assignment is due soon... i hope help arrives..
chronos
chronosOP12mo ago
No description
chronos
chronosOP12mo ago
what does this mean.. nvm IT WORKS solved. got it.
Want results from more Discord servers?
Add your server