How to clear last wxListBox result?
Posted: Sat Feb 18, 2012 1:13 am
Hello again, full of questions tonight:
I have a wxListBox, of which I am allowing the user to delete items through a button. When I do deletion, I check which array item is selected, remove that result, and everything is fine... up until the user attempts to delete the last result. Since I'm essentially removing the selected item from the wxArrayString, I'm guessing the problem is coming from attempting to redraw the list with no items in that array.
SymbolListStrings is the wxArrayString, and SymbolList is the wxListBox. It works fine the way I have it in the above code, except that I don't want to have an item in the wxListBox that is empty. Is there any way to reset the wxListBox without any items in it?
FlyingIsFun1217
I have a wxListBox, of which I am allowing the user to delete items through a button. When I do deletion, I check which array item is selected, remove that result, and everything is fine... up until the user attempts to delete the last result. Since I'm essentially removing the selected item from the wxArrayString, I'm guessing the problem is coming from attempting to redraw the list with no items in that array.
Code: Select all
for(int i = 0; i <= (SymbolListStrings.GetCount() - 1); i++)
{
if(SymbolList -> IsSelected(i))
{
if(SymbolListStrings.GetCount() > 1)
{
SymbolListStrings.RemoveAt(i, 1);
}
else if(SymbolListStrings.GetCount() == 1)
{
SymbolListStrings.Clear();
SymbolListStrings.Add(wxT(""));
}
SymbolList -> Set(SymbolListStrings);
}
}
FlyingIsFun1217