本文整理匯總了C#中System.Windows.Forms.ListBox.PointToClient方法的典型用法代碼示例。如果您正苦於以下問題:C# ListBox.PointToClient方法的具體用法?C# ListBox.PointToClient怎麽用?C# ListBox.PointToClient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.ListBox
的用法示例。
在下文中一共展示了ListBox.PointToClient方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Setline
private void Setline(ListBox target, bool visible, DragEventArgs e)
{
panel1.Visible = visible;
if (target == null)
{
return;
}
Point p = new Point(e.X, e.Y);
p = (target).PointToClient(p);
int indexOfItem = EventBox.IndexFromPoint(p.X, p.Y);
int y = target.PointToClient(p).Y;
int x1 = target.Left;
int x2 = target.Width;
int ih = target.ItemHeight;
int y1 = (int)Math.Min(Math.Round((double)(y / ih)),target.Items.Count) * ih + target.Top;
panel1.Left = x1;
panel1.Top = y1;
panel1.Width = x2;
panel1.Height = 2;
}
示例2: getIndex
private int getIndex(ListBox list, int x, int y)
{
Point point = list.PointToClient(new Point(x, y));
int index = list.IndexFromPoint(point);
if (index < 0) { index = list.Items.Count - 1; } //off the end of the list
return index;
}