I have two datagrid's in my project and I wanto to move element from first datagrid to second one, and remove it from the first. As far as copying works great i can't remove selected item from first datagrid. Both datargids are binded with observablecollection
private void Button_Click(object sender, RoutedEventArgs e)
{
productionplan.Add(lstorder.SelectedItem as OrderItem); //creates a copy in second datagrid
orderedlist.RemoveAt(lstorder.SelectedIndex); //should remove from first datagrid
}
it throws exception "Object reference not set to an instance of an object"
I have no idea why...
Thansk for help!
Instead you can do this,
private void Button_Click(object sender, RoutedEventArgs e)
{
productionplan.Add(lstorder.SelectedItem as OrderItem);
orderedlist.Remove(OrderItem);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.