How to Achieve ExcelLikeFillSelection in SfDataGrid

I want to achieve ExcelLikeFillSelection feature in SfDataGrid Control.
In other words, I want user to be able to start drag from one cell and drop a few cells after in vertically down direction and be able to copy cell values.
Please find attached Syncfusion Sample, it has desired behaviour I want, but it is designed for GridControl.

How do I achieve the same for SfDataGrid ? 


Thanking you,
Rahul Makwana

Attachment: Excel_Like_Fill_Selection_9b4204c3.7z

3 Replies

GT Gnanasownthari Thirugnanam Syncfusion Team November 29, 2017 12:14 PM UTC

Hi Rahul, 

We cannot provide direct support for ExcellLikeFillSelection feature like GridControl but you can achieve your requirement in SfDataGrid by customize the GridCellSelectionController class. In this sample we have get the first selected cell value and set the value to all dragged cells in ProcessPointerRelease method. 
 
We have prepared the sample based on your requirement, you can download it from below mentioned location. 
 
 
Regards, 
Gnanasownthari T. 
 



RU Russ May 24, 2026 01:20 PM UTC

Would there be a way of doing this without preventing rows from being selected?



SR Senthilkumar Ranganathan Syncfusion Team May 25, 2026 12:38 PM UTC

Russ,

Based on your requirement, this can be achieved by customizing the GridSelectionController class. Within this class, as mentioned earlier, you can retrieve the first selected cell value and apply it to all dragged cells in the ProcessPointerReleased method.

Additionally, to enable row selection, ensure that the SelectionUnit property is set to Row.

Code Snippet for Excel-like Fill Selection with Row Selection:
//You can assign GridSelectionController here for row selection. this.datagrid.SelectionController = new GridSelectionControlExt(this.datagrid);

protected override void ProcessPointerReleased(     MouseButtonEventArgs args,     Syncfusion.UI.Xaml.ScrollAxis.RowColumnIndex rowColumnIndex) {     base.ProcessPointerReleased(args, rowColumnIndex);     if (!isDragged)         return;     selectedRowsCollection = this.SelectedRows;     if (selectedRowsCollection == null || selectedRowsCollection.Count == 0)     {         Reset();         return;     }     var mappingName = this.DataGrid.Columns[rowColumnIndex.ColumnIndex].MappingName;     var firstRowData = selectedRowsCollection[0].RowData;     var property = firstRowData.GetType().GetProperty(mappingName);     if (property == null)     {         Reset();         return;     }     selectedFirstCellValue = property.GetValue(firstRowData);     for (int i = 1; i < selectedRowsCollection.Count; i++)     {         var rowData = selectedRowsCollection[i].RowData;         property.SetValue(rowData, selectedFirstCellValue);     }     Reset(); } private void Reset() {     isDragged = false;     selectedFirstCellValue = null;     selectedRowsCollection?.Clear(); }

Gif Illustration:
 

Please find the modified sample demo in the attachment.

Attachment: SfDataGridDemo_c09037a7.zip

Loader.
Up arrow icon