MouseEventArgs.Y Свойство
Определение
Возвращает координату Y указателя мыши в момент создания события мыши.Gets the y-coordinate of the mouse during the generating mouse event.
public:
property int Y { int get(); };
public int Y { get; }
member this.Y : int
Public ReadOnly Property Y As Integer
Значение свойства
Координата Y указателя мыши в пикселях.The y-coordinate of the mouse, in pixels.
Примеры
В следующем примере кода X Свойства и используются Y для вывода текущей позиции указателя мыши в ToolTip окне.The following code example uses the X and Y properties to display the current position of the mouse pointer in a ToolTip window. Чтобы использовать этот код, вызовите TrackCoordinates
из конструктора формы.To use this code, call TrackCoordinates
from the form constructor.
ToolTip trackTip;
private void TrackCoordinates()
{
trackTip = new ToolTip();
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
}
void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
String tipText = String.Format("({0}, {1})", e.X, e.Y);
trackTip.Show(tipText, this, e.Location);
}
Dim TrackTip As ToolTip
Private Sub TrackCoordinates()
TrackTip = New ToolTip()
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Dim TipText As String = String.Format("({0}, {1})", e.X, e.Y)
TrackTip.Show(TipText, Me, e.Location)
End Sub
Комментарии
Координаты мыши меняются в зависимости от вызываемого события.The mouse coordinates vary based on the event being raised. Например, при Control.MouseMove обработке события значения координат мыши задаются относительно координат элемента управления, вызвавшего событие.For example, when the Control.MouseMove event is handled, the mouse coordinate values are relative to the coordinates of the control that raised the event. Некоторые события, связанные с операциями перетаскивания, имеют связанные значения координат мыши относительно начала формы или с начала экрана.Some events related to drag-and-drop operations have associated mouse coordinate values that are relative to the form origin or the screen origin.