hi
How to Achieve ExcelLikeFillSelection in SfDataGrid with red border and Cross Cursor?
This features is available in GridControl, but not in SfSatagrid
Hi Ali,
We are a little unclear about your
scenario, but we suspect that your requirement is
to "Select multiple cells with dragging" which will be achievable by using the SelectionMode
as Extended
or Multiple and SelectionUnit
as Cell has shown below,
Multiple SelectionMode:
<Syncfusion:SfDataGrid x:Name="dataGrid" AutoGenerateColumns="False" SelectionMode="Multiple" SelectionUnit="Cell" ItemsSource="{Binding Orders}" /> |
Extended SelectionMode:
<Syncfusion:SfDataGrid x:Name="dataGrid" AutoGenerateColumns="False" SelectionMode="Extended" SelectionUnit="Cell" ItemsSource="{Binding Orders}" /> |
If we misunderstood your requirement, please provide more information regarding it. If you need to update the selection only or change the Value while performing the DragSelection? Also, you have mentioned that the required behavior is also available in GridControl; could you please confirm whether you have mentioned an Excel-like selection frame If not, please share more information about this. It would help us to proceed further.
Regards,
Dhanasekar M.
thank you
Ali,
We have checked the feasibility of
achieving your requirement. Our SfDatagrid does not contain any direct support
to achieve your requirement. However, you can copy one cell and paste it into
the selected cell by creating the CustomGridCopyPaste in SfDataGrid. GridCopyPaste
class has many overrides to customize copy and paste operations. To
achieve the above, you can override the PasteToCells
(object clipboardrows) shown below,
this.sfdatagrid.GridCopyPaste = new CustomCopyPaste(sfdatagrid);
{ public CustomCopyPaste(SfDataGrid sfgrid) : base(sfgrid) { } protected override void PasteToCells(object clipboardrows) { var data = (IList)clipboardrows; var firstrowdata = Regex.Split(data[0].ToString(), @"\t"); //Gets the ClipboardText and checks when the clipboard text is more than one cell // calls the base. if (data.Count > 1 || firstrowdata.Count() > 1) { base.PasteToCells(clipboardrows); return; } //Gets the selected cells to paste the copied cell var selectedcells = this.dataGrid.GetSelectedCells(); int selectedcellscount = selectedcells.Count; for (int i = 0; i < selectedcellscount; i++) { var record = selectedcells[i].RowData; var column = selectedcells[i].Column; //Calls PasteToCell method with particular record of selectedcells, // Column of selected records and rowdata PasteToCell(record, column, data[0]); } } } |
For more information related to customizing Copy/Paste behavior, please refer to the below user guide documentation link,
Please
find the sample in the attachment.
If this post is helpful, please consider Accepting it as the solution so that
other members can locate it more quickly.