Hi,
i am using a datagrid control using 3 columns first column with checkbox header as well as rows if i select header checkbox i need all the rows to be selected and if i unselect all the rows to be unselected and also i have a delete button outside of the datagrid. if i check header checkbox and perform delete operation i need all the rows to be delete and if i select individual record should be delete.how to acheive this .Thanks
Shweta LodhaPosted Jan 2, 2017, 11:56 PM
One readymade solution is also available here:
https://www.codeproject.com/questions/484312/howplustoplusselectplusallpluscheckboxplusofplusap
Shweta LodhaPosted Jan 2, 2017, 11:55 PM
sai,
As you mentioned that you have a checkbox at header level. So, in that case you can take a property SelectAll in your viewModel and update your item source collections like:
Shweta LodhaPosted Jan 2, 2017, 6:36 AM
AshokPosted Jan 2, 2017, 6:29 AM
Shweta LodhaPosted Dec 26, 2016, 10:17 AM
Hello Sai,
You need not to call the event explicitly. In xaml, simply register this at DataGrid level as
AshokPosted Dec 23, 2016, 1:20 AM
Amit GuptaPosted Dec 21, 2016, 3:17 AM
AshokPosted Dec 21, 2016, 12:43 AM
AshokPosted Dec 20, 2016, 1:30 AM
Shweta LodhaPosted Dec 16, 2016, 3:58 AM
Hi,
A complete sample is given over here: http://www.devcurry.com/2011/04/wpf-4-datagrid-delete-multiple-rows.html
DataGridRowEditEndingEventArgs e)
{
FrameworkElement element = dgEmp.Columns[4].GetCellContent(e.Row);
if (element.GetType() == typeof(CheckBox))
{
if (((CheckBox)element).IsChecked == true)
{
FrameworkElement cellEmpNo =
dgEmp.Columns[0].GetCellContent(e.Row);
int EmpNo = Convert.ToInt32(((TextBlock)cellEmpNo).Text);
lstSelectedEmpNo.Add(EmpNo);
}
}
}
Amit GuptaPosted Dec 16, 2016, 3:51 AM