English 中文(简体)
点击控制
原标题:Get the point of click on a control

I am using an old ActiveX control in my C# Win App. it has a MouseUp event that its eventArgs is passing the X and Y of the point that we have clicked but for my scenario I am using its ItemClick event and its eventArgs does not have the info about X and Y. but I need to know them to show my pop-up... so is there a way I can find out what is the location of X and Y that user has right-clicked so I can pass it to my contextMenuStrip.Show method.

增 编

最佳回答

管制班有一个静读的MousePosition Property,这给屏幕上的模拟坐标。 你们可以利用这一机会了解如何定位背景。

来自MSDN:

控制。 财产

类型:系统.Drawing.Point

A Point that contains the coordinates of the mouse cursor relative to the upper-left corner of the screen.

问题回答

<代码>Cursor.Position>将接见目前 cur的屏幕坐标。 大部分用途都足够了,尽管烟雾可能从点击到被点击手之间移动。

你们需要获得具备屏幕位置的曲线位置,然后从控制范围内叫ToClient,以便把相关点控制起来。 Aka. 0,0 是控制的最大左侧。

this.PointToClient(Cursor.Position);

页: 1





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签