C
C#13mo ago
chronos

listbox display help !

Any idea why this listbox isnt working?
No description
No description
No description
31 Replies
chronos
chronosOP13mo ago
No description
chronos
chronosOP13mo 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
Jimmacle13mo 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
chronosOP13mo 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
Jimmacle13mo ago
you need to override that method in your Item class
chronos
chronosOP13mo ago
errr
Jimmacle
Jimmacle13mo ago
like
public override string ToString()
{
return ItemName;
}
public override string ToString()
{
return ItemName;
}
chronos
chronosOP13mo ago
oh yeah silly me i’ve done that before in this project already
chronos
chronosOP13mo ago
No description
chronos
chronosOP13mo ago
hmm
Jimmacle
Jimmacle13mo ago
why are you writing that?
chronos
chronosOP13mo ago
um to convert it to a string.. : P
Jimmacle
Jimmacle13mo ago
you don't need to
chronos
chronosOP13mo ago
well
Jimmacle
Jimmacle13mo ago
winforms is calling it itself
chronos
chronosOP13mo 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
Jimmacle13mo ago
store one where?
chronos
chronosOP13mo ago
No description
chronos
chronosOP13mo ago
when i try to add more items nothing happens
Jimmacle
Jimmacle13mo ago
if you update the list you need to tell winforms it updated somehow
chronos
chronosOP13mo ago
only the first is registered
Jimmacle
Jimmacle13mo ago
which is where my knowledge of winforms stops
chronos
chronosOP13mo ago
i shall look this up
Jimmacle
Jimmacle13mo ago
i don't know if winforms has data binding but that's what i'd use in other frameworks
chronos
chronosOP13mo ago
i think it’s just .Refresh ok nope anyone else know what’s up with this
chronos
chronosOP13mo ago
No description
chronos
chronosOP13mo ago
it just displays the first item i get and nothing else
chronos
chronosOP13mo ago
No description
chronos
chronosOP13mo ago
my assignment is due soon... i hope help arrives..
chronos
chronosOP13mo ago
No description
chronos
chronosOP13mo ago
what does this mean.. nvm IT WORKS solved. got it.

Did you find this page helpful?