Spread Windows Forms 7.0 Product Documentation
GetColumnViewportIndexFromX Method
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > FpSpread Class : GetColumnViewportIndexFromX Method


x
X-coordinate

Glossary Item Box

Gets the index of the viewport column for the specified coordinate for the active sheet.

Syntax

Visual Basic (Declaration) 
Public Function GetColumnViewportIndexFromX( _
   ByVal x As Integer _
) As Integer
Visual Basic (Usage)Copy Code
Dim instance As FpSpread
Dim x As Integer
Dim value As Integer
 
value = instance.GetColumnViewportIndexFromX(x)
C# 
public int GetColumnViewportIndexFromX( 
   int x
)

Parameters

x
X-coordinate

Return Value

Integer index of 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 returns the viewport the user clicks in.
C#Copy Code
private void fpSpread1MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
     int i;
     i = fpSpread1.GetRootWorkbook.GetColumnViewportIndexFromX(e.X);
     Debug.WriteLine(i.ToString);
}
Visual BasicCopy Code
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

Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8

See Also

Reference

FpSpread Class
FpSpread Members

User-Task Documentation

Customizing Viewports

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.