Why do I get an OutOfMemoryException when I have images in my ListBox?

Oh, I recently killed whole day to make this working! So the solution is: Make your Image control free resources. So set the BitmapImage bitmapImage = image.Source as BitmapImage; bitmapImage.UriSource = null; image.Source = null; as it was mentioned before. Make sure you virtualize _bitmap on every item of the list. You should load it … Read more

Databinding to List – See changes of data source in ListBox, ComboBox

In Windows Forms, in a scenario that you want to see changes of data source in the bound list control, like ComboBox, ListBox or DataGridView (complex two-way data binding), you should use a class that implements IBindingList interface as DataSource of data binding. The most suitable implementation is BindingList<T>. This way each add/remove in the … Read more

Trim String to int, then char to string, Listbox to textbox

A format exception, according to the documentation means: value does not consist of an optional sign followed by a sequence of digits (0 through 9). Whatever you’re getting on this line: string test = listBox2.SelectedItem.ToString().Trim(); Is not an parse-able integer. You should debug to figure out what the value is that you’re actually getting. Hint: … Read more