Spread Windows Forms 12.0 Product Documentation
GetColumnViewportIndexFromX Method (SpreadView)
Example 


FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SpreadView Class : GetColumnViewportIndexFromX Method
X coordinate
Gets the index of the viewport column for the specified coordinate for the active sheet.
Syntax
'Declaration
 
Public Function GetColumnViewportIndexFromX( _
   ByVal x As Integer _
) As Integer
'Usage
 
Dim instance As SpreadView
Dim x As Integer
Dim value As Integer
 
value = instance.GetColumnViewportIndexFromX(x)
public int GetColumnViewportIndexFromX( 
   int x
)

Parameters

x
X coordinate

Return Value

Integer index of the viewport column
Remarks

This method (along with GetRowViewportIndexFromY) allows you to retrieve the index of the viewport row or viewport column from pixel offsets. This is useful in mouse-handling to see in which viewport a mouse event (MouseDown, MouseMove, etc.) occurred.

The viewport column index is zero-based, so the first (leftmost) viewport column has an index of 0.

Example
This example uses the GetColumnViewportIndexFromX method.
private void fpSpread1MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
     int i;
     i = fpSpread1.GetRootWorkbook.GetColumnViewportIndexFromX(e.X);
     Debug.WriteLine(i.ToString);
}
Private Sub fpSpread1MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles fpSpread1.MouseDown
     Dim i As Integer
     i = fpSpread1.GetRootWorkbook.GetColumnViewportIndexFromX(e.X)
     Debug.WriteLine(i.ToString)
End Sub
See Also

Reference

SpreadView Class
SpreadView Members

User-Task Documentation

Customizing Viewports