I currently have a listbox, which when selected, pulls gif images from the database to display in a listbox.
private void Btn_Click(object sender, RoutedEventArgs e) { SQLiteConnection sqliteCon = new SQLiteConnection(dbConnectionString); sqliteCon.Open(); string SelectionQuery = "SELECT gif FROM myTable WHERE Style = 'Jump'"; SQLiteDataAdapter adapter = new SQLiteDataAdapter(SelectionQuery, sqliteCon); DataTable dt = new DataTable(); adapter.Fill(dt); DataView source = myListBox.ItemsSource as DataView; foreach(DataRow dr in dt.Rows) { source.Table.ImportRow(dr); } myListBox.ItemsSource = null; myListBox.ItemsSource = source; }
I would now like to have the gif selected from the listbox be removed from the listbox when the delete button is selected. I've tried the following but did not work....A simple solution would be appreciated...thanks in advance.
private void DeleteStepsBtn_Click(object sender, RoutedEventArgs e)
{
myListBox.Items.RemoveAt
(myListBox.Items.IndexOf(myListBox.SelectedItem));
}
I also tried:
private void DeleteStepsBtn_Click(object sender, RoutedEventArgs e)
{
myListBox.RemoveItem(a);
}