Hi Bradley Wheeler,
Thank you for contacting Syncfusion support.
We suspect that your enable the SelectionMode property value as Single So selection not applied. If you want to select the multiple row you need to set the SelectionMode value as Multiple in SfDataGrid. Please refer the below user documentation,
UG Link: https://help.syncfusion.com/windowsforms/datagrid/selection#multiple-row-or-cell-selectionIf we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further.
Regards,
Vijayarasan S
private void SfDataGrid1_SelectionChanging(object sender, Syncfusion.WinForms.DataGrid.Events.SelectionChangingEventArgs e)
{
var records = sfDataGrid1.View.Records;
foreach (var record in records)
{
var dataRowView = record.Data as DataRowView;
if (dataRowView != null)
{
if (dataRowView["Gender"].ToString() == "Male")
{
sfDataGrid1.BeginInvoke(new Action(() =>
{
sfDataGrid1.SelectedItems.Add(record.Data);
}));
}
}
}
} |
private void SfDataGrid1_SelectionChanging(object sender, Syncfusion.WinForms.DataGrid.Events.SelectionChangingEventArgs e)
{
if (sfDataGrid1.CurrentItem is DataRowView selectedItem)
{
var dataRow = (selectedItem as DataRowView).Row;
if (dataRow != null)
{
var records = sfDataGrid1.View.Records;
foreach (var record in records)
{
var dataRowView = record.Data as DataRowView;
if (dataRowView != null)
{
if (dataRowView["Country"].ToString() == dataRow["Country"].ToString())
{
sfDataGrid1.BeginInvoke(new Action(() =>
{
sfDataGrid1.SelectedItems.Add(record.Data);
}));
}
if (dataRowView["ShipCity"].ToString() == "London")
{
sfDataGrid1.BeginInvoke(new Action(() =>
{
sfDataGrid1.SelectedItems.Add(record.Data);
}));
}
}
}
}
}
} |