I would like to be able to show users what cell they have moving over without clicking on the cell. Is there a way to determine the cell from the x,y coordinates?
Thanks
Hi Mike,
Don't worry about my query above, I found the GetCellBoundsInTwips function and can do everything I need with the cell position.
Sort of related, is there a way to get the location/size of that cell that the user has just moved over (and been returned by the hittest)? I'd like to pop up my own control over the cell, using the cell's position and dimensions.
Thanks!
Hi Nick,
Yes, you can use the HitTest method.
private void ultraSpreadsheet1_MouseMove(object sender, MouseEventArgs e) { var spreadsheet = (UltraSpreadsheet)sender; var cell = GetCellFromPoint(spreadsheet, e.Location); Debug.WriteLine(cell); } private static SpreadsheetCell? GetCellFromPoint(UltraSpreadsheet spreadsheet, PointF location) { var hitTestResult = spreadsheet.HitTest(location); var spreadsheetCellHitTestResult = hitTestResult as SpreadsheetCellHitTestResult; if (null != spreadsheetCellHitTestResult) { return spreadsheetCellHitTestResult.Cell; } return null; }
private void ultraSpreadsheet1_MouseMove(object sender, MouseEventArgs e) { var spreadsheet = (UltraSpreadsheet)sender; var cell = GetCellFromPoint(spreadsheet, e.Location); Debug.WriteLine(cell); }
private static SpreadsheetCell? GetCellFromPoint(UltraSpreadsheet spreadsheet, PointF location) { var hitTestResult = spreadsheet.HitTest(location);
var spreadsheetCellHitTestResult = hitTestResult as SpreadsheetCellHitTestResult; if (null != spreadsheetCellHitTestResult) { return spreadsheetCellHitTestResult.Cell; }
return null; }