Free Support Forum - aspose.com

Drag n Drop?

Hi

I am using Desktop.Grid with VB.Net

How do I allow the users to Drag n Drop either single cell or multi cells?

I have looked at documentation and can't find any information

Regards

Bob Hamill

Hi Bob,

Currently the drag and drop ( of cells) feature is not available although you may copy and paste cells data (right-click on the cell(s)) in the worksheet. We may consider this feature and support it in our future versions of Aspose.Grid.Desktop.

Thank you.

Hi

Thanks for quick reply.

I cannot use copy and paste because I want to accumulate the figures from selected cells and put result in other cell - so

I want to put a button on the sheet - the user will select single/multi cells and press the button - the figures will then be accumulated and moved to a predesignated cell.

The question is - I know how to access data from a single cell - how do I access data from multi cells that a user has selected?

Regards

Bob Hamill

Hi Bob,

I thought you mean drag / drop a cell by mouse same as MS Excel.

Well, you may do it. Following is my sample code which works fine and demonstrates a way to achieve this. You may simply select a range of cells in the worksheet, the code just adds the data and puts the summary result to "F20" cell.

Dim sheet As Aspose.Grid.Desktop.Worksheet = Me.GridDesktop1.GetActiveWorksheet()
Dim range As Aspose.Grid.Desktop.CellRange = sheet.GetLastSelection()
Dim i As Integer
Dim j As Integer
Dim sum As Integer
For i = range.StartRow To range.EndRow
For j = range.StartColumn To range.EndColumn
sum = sum + sheet.Cells(i, j).Value
Next
Next

Dim cell As GridCell = sheet.Cells("F20")
cell.SetCellValue(sum)
Thank you.