Hello. I'm using SfDataGrid to build a Hex Viewer (Winui3 Desktop / .NET 6.0) but I'm blocked by the cell selection modes available.
If I start selecting a cell and move to the row below, I get selected only the cells in the row below. What I'm trying to do is to make SfDataGrid to select all cells to the right of the first one and to continue the selection until I reach the last cell I need to select (see pictures attached, please).
Could you add this kind of selection to modes already available, please? If not, what you would suggest to achieve this result?
I played a lot with SelectionChanging and SelectionChanged events by trying to programmatic select the cells between the first and the last in the e.AddedItems args but I always get the values of the first and the last ones, not of the whole set of cells I'm trying to select.
Hi ZipGenius Team,
We have analyzed the requested scenario in our end. We regret to let you know
that there is no selection modes available for sequential selection. SfDataGrid
architecture does not support sequential selection. For sequential
selection we need to gather all previous selected items notifications. It is
not possible in SfDataGrid and it is default behavior. In programmatic
selection if we provide start index and end index it may be possible to add the
in-between column records as selected items. Currently, we are checking the
feasibilities for this. We will update the details on May 6, 2022. But in UI
selection it is not possible.
Regards,
Dhanasekar M.
Hello. Thank you for your reply.
Somehow I managed to achieve that result and I'm able to select cells in a range by clicking on a starting cell and then on a an ending cell. When I get columns and rows for the two cells, I can select all the in-between cells by using a loop and DataGrid1.SelectCell(x,y); anyway another issue arose while testing.
If I scroll the DataGrid until the selected cells go off-screen and then go back to where I was, the DataGrid shows only the starting and the ending cells of the range I selected, while all the in-betweens.
I recorded a video that I put in a zip file attached to this post.
This looks like a rendering bug to me.
Why cells selected with SelectCell() got deselected upon scrolling?
Hi ZipGenius Team,
Based on provided information, we have checked the reported issue in our end.
We regret to that let you know the reported issue not replicated, its works as
expected. The selected cells retain properly while scrolling. Here we have
attached the tested sample and video. Please check this if you still facing the
issue, please modified the provided sample based on your scenario. It will be helpful
for us to understand the exact problem and to provide you a prompt solution at
the earliest.
Regards,
Dhanasekar M.
Unbelievable. I managed to avoid deselection because of your sample.
In my code I was using:
var x = DataGrid1.View.GetRecordAt(r - 1);
Adding ".Data" did the trick.
var x = DataGrid1.View.GetRecordAt(r - 1).Data;You should add this case to documentation abot custom selection of cells because my code was working without ".Data" except for the issue I reported.
Many Thanks!