ListViewItem.GetSubItemAt 方法 取坐标

简介: 代码 private ListView listView1;private void  InitializeListView1(){    listView1 = new ListView();        // Set the view to details to show subitems.
img_405b18b4b6584ae338e0f6ecaf736533.gif 代码
private  ListView listView1;

private   void   InitializeListView1(){
    listView1 
=   new  ListView();
    
    
//  Set the view to details to show subitems.
    listView1.View  =  View.Details;
   
    
//  Add some columns and set the width.
    listView1.Columns.Add( " Name " );
    listView1.Columns.Add(
" Number " );
    listView1.Columns.Add(
" Description " );
    listView1.Width 
=   175 ;

    
//  Create some items and subitems; add the to the ListView.
    ListViewItem item1  =   new  ListViewItem( " Widget " );
    item1.SubItems.Add(
new  ListViewItem.ListViewSubItem(item1,  " 14 " ));
    item1.SubItems.Add(
new  ListViewItem.ListViewSubItem(item1, 
        
" A description of Widget " ));
    ListViewItem item2 
=   new  ListViewItem( " Bracket " );
    item2.SubItems.Add(
new  ListViewItem.ListViewSubItem(item2,  " 8 " ));
    listView1.Items.Add(item1);
    listView1.Items.Add(item2);
    
    
//  Add the ListView to the form.
     this .Controls.Add(listView1);
    listView1.MouseDown 
+=   new  MouseEventHandler(listView1_MouseDown);
}

void  listView1_MouseDown( object  sender, MouseEventArgs e)
{
    
//  Get the item at the mouse pointer.
    ListViewHitTestInfo info  =  listView1.HitTest(e.X, e.Y);

    ListViewItem.ListViewSubItem subItem 
=   null ;
    
    
//  Get the subitem 120 pixels to the right.
     if  (info  !=   null )
        
if  (info.Item  !=   null )
            subItem 
=  info.Item.GetSubItemAt(e.X  +   120 , e.Y);
    
    
//  Show the text of the subitem, if found.
     if  (subItem  !=   null )
        MessageBox.Show(subItem.Text);
}

 

命名空间: System.Windows.Forms
程序集: System.Windows.Forms(在 system.windows.forms.dll 中)
目录
相关文章
|
8月前
两个坐标间画线
两个坐标间画线
39 3
|
8月前
|
API C++ 计算机视觉
【opencv3】鼠标框选矩形并显示当前像素点坐标和矩形中心点坐标C++
【opencv3】鼠标框选矩形并显示当前像素点坐标和矩形中心点坐标C++
|
3月前
ThreeJs通过射线获取自己的点击位置坐标
这篇文章详细说明了如何使用Three.js来绘制线条,包括创建线几何体、设置材质以及将线条添加到3D场景中的具体步骤。
153 1
ThreeJs通过射线获取自己的点击位置坐标
|
5月前
|
算法 C++
大地经纬度坐标与地心地固坐标的的转换
大地经纬度坐标与地心地固坐标的的转换
134 0
|
定位技术
任意一张图片的CGCS2000坐标配准
任意一张图片的CGCS2000坐标配准
168 0
如何判断投影坐标是 3 度带还是 6 度带?如何计算中央子午线经度?
如何判断投影坐标是 3 度带还是 6 度带?如何计算中央子午线经度?
给定三个顶点的坐标使用程序计算三角形
给定三个顶点的坐标使用程序计算三角形
86 0
|
移动开发 C++
C/C++编程题之坐标移动
开发一个坐标计算工具, A表示向左移动,D表示向右移动,W表示向上移动,S表示向下移动。从(0,0)点开始移动,从输入字符串里面读取一些坐标,并将最终输入结果输出到输出文件里面。
Halcon示例之求一个矩形四个角点坐标的八种方法
Halcon示例之求一个矩形四个角点坐标的八种方法
1758 0
Halcon示例之求一个矩形四个角点坐标的八种方法