当前位置: 首页>>代码示例>>C#>>正文


C# ListViewInsertionMark.AppearsAfterItem属性代码示例

本文整理汇总了C#中System.Windows.Forms.ListViewInsertionMark.AppearsAfterItem属性的典型用法代码示例。如果您正苦于以下问题:C# ListViewInsertionMark.AppearsAfterItem属性的具体用法?C# ListViewInsertionMark.AppearsAfterItem怎么用?C# ListViewInsertionMark.AppearsAfterItem使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Windows.Forms.ListViewInsertionMark的用法示例。


在下文中一共展示了ListViewInsertionMark.AppearsAfterItem属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: myListView_DragOver

// Moves the insertion mark as the item is dragged.
private void myListView_DragOver(object sender, DragEventArgs e)
{
    // Retrieve the client coordinates of the mouse pointer.
    Point targetPoint = 
        myListView.PointToClient(new Point(e.X, e.Y));

    // Retrieve the index of the item closest to the mouse pointer.
    int targetIndex = myListView.InsertionMark.NearestIndex(targetPoint);

    // Confirm that the mouse pointer is not over the dragged item.
    if (targetIndex > -1) 
    {
        // Determine whether the mouse pointer is to the left or
        // the right of the midpoint of the closest item and set
        // the InsertionMark.AppearsAfterItem property accordingly.
        Rectangle itemBounds = myListView.GetItemRect(targetIndex);
        if ( targetPoint.X > itemBounds.Left + (itemBounds.Width / 2) )
        {
            myListView.InsertionMark.AppearsAfterItem = true;
        }
        else
        {
            myListView.InsertionMark.AppearsAfterItem = false;
        }
    }

    // Set the location of the insertion mark. If the mouse is
    // over the dragged item, the targetIndex value is -1 and
    // the insertion mark disappears.
    myListView.InsertionMark.Index = targetIndex;
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:32,代码来源:ListViewInsertionMark.AppearsAfterItem


注:本文中的System.Windows.Forms.ListViewInsertionMark.AppearsAfterItem属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。