SpreadsheetGear 2023
LocationToRange(Point) Method
Example 


SpreadsheetGear.Windows.Forms Namespace > WorkbookView Class > LocationToRange Method : LocationToRange(Point) Method
Specifies the location.
Returns an instance of IRange representing the cell at the specified location or null if there is none.
Syntax
'Declaration
 
Public Overloads Function LocationToRange( _
   ByVal location As System.Drawing.Point _
) As IRange
'Usage
 
Dim instance As WorkbookView
Dim location As System.Drawing.Point
Dim value As IRange
 
value = instance.LocationToRange(location)
public IRange LocationToRange( 
   System.Drawing.Point location
)

Parameters

location
Specifies the location.

Return Value

An instance of IRange representing the cell at the specified location or null if there is none
Example
/*
         * Demonstrate using the WorkbookView.LocationToRange method to convert
         * from mouse coordinates to an instance of SpreadsheetGear.IRange.
         */
        private void workbookView_MouseDown(object sender, MouseEventArgs e)
        {
            // Acquire a lock on the workbook set.
            workbookView.GetLock();
            try
            {
                // Get the range associated with the mouse location.
                SpreadsheetGear.IRange range =
                    workbookView.LocationToRange(e.Location);
 
                // If this location contains a range, set the interior to blue.
                if (range != null)
                    range.EntireMergeArea.Interior.Color = Color.Blue;
            }
            finally
            {
                // Release the lock on the workbook set.
                workbookView.ReleaseLock();
            }
        }
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

WorkbookView Class
WorkbookView Members
Overload List