Spread Windows Forms 13.0 Product Documentation
FarPoint.Win.Spread Assembly / FarPoint.Win.Spread Namespace / FpSpread Class / GetCellFromPixel Method
Index of the row of the viewport
Index of the column of the viewport
X-coordinate of the pointer location
Y-coordinate of the pointer location

In This Topic
    GetCellFromPixel Method (FpSpread)
    In This Topic
    Gets the row and column indexes of the cell at the specified pointer location.
    Public Function GetCellFromPixel( _
       ByVal rowViewportIndex As Integer, _
       ByVal columnViewportIndex As Integer, _
       ByVal x As Integer, _
       ByVal y As Integer _
    ) As CellRange
    Dim instance As FpSpread
    Dim rowViewportIndex As Integer
    Dim columnViewportIndex As Integer
    Dim x As Integer
    Dim y As Integer
    Dim value As CellRange
    value = instance.GetCellFromPixel(rowViewportIndex, columnViewportIndex, x, y)
    public CellRange GetCellFromPixel( 
       int rowViewportIndex,
       int columnViewportIndex,
       int x,
       int y


    Index of the row of the viewport
    Index of the column of the viewport
    X-coordinate of the pointer location
    Y-coordinate of the pointer location

    Return Value

    CellRange object containing the cell

    This method returns a CellRange object that consists of row and column coordinates and row and column counts. If a cell exists at the pixel location, then the method returns CellRange(row, column, 1, 1) where row, column are the row index and column index of the cell. If a cell does not exist at the pixel location then the method returns CellRange(-1,-1,-1,-1).

    Use the x and y parameters to specify the location (pixel) on the display and use the rowviewportindex and columnviewportindex parameters to specify a particular viewport.

    This method only returns cell information for pixel locations in the data area of the sheet, and not for headers or sheet corner or other parts of the Spread component. For cells in the column headers and row headers, use the GetColumnHeaderCellFromPixel and GetRowHeaderCellFromPixel methods.

    This example gets the cell located at the specified pointer location.
    private void fpSpread1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
         FarPoint.Win.Spread.Model.CellRange range = fpSpread2.GetCellFromPixel(0, 0, e.X, e.Y);
         listBox1.Items.Add("range: row=" + range.Row.ToString() + " column=" + range.Column.ToString());
    Private Sub FpSpread1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles      FpSpread1.MouseDown
         Dim range As FarPoint.Win.Spread.Model.CellRange = FpSpread2.GetCellFromPixel(0, 0, e.X, e.Y)
         ListBox1.Items.Add("range: row=" & range.Row.ToString() & " column=" & range.Column.ToString())
    End Sub
    See Also