i've done like you proposed, it's my code:
CheesDrawing.Player.csPlayer Player =
(CheesDrawing.Player.csPlayer)lstPlayers.SelectedI tem;
Player.Name = txtName.Text;
lstPlayers.Items[lstPlayers.SelectedIndex] = Player;
third line throws exeption:
"object reference not set to an instance of an object"
"PL Patrick" <ne********@user.pl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,
int selectedIndex = ListBox.SelectedIndex;
MyClass selectedItem = (MyClass)ListBox.SelectedItem;
....
selectedItem.Property = newProperty;
....
ListBox.Items[selectedIndex] = selectedItem;
I've class derived from "Object" class, with ToString() method overriden
itc. ,
now i add object of this class to Windows.Forms.ListBox.Items
collection, and it works fine, displaying what ToString() should
return...
then the program is in the runtime, i chage fields of this object in
thet way ( (MyClass)ListBox.SelectedItem ).SomeProperty = newValue;
so ToString() method now will return new value, but text showed in a
listbox itself not changes, i tried to call ListBox.Update(), adn ListBox.Text =
"", but nothing worked...
What can i do?