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


C# ListView.GetItemAt方法代码示例

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


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

示例1: ShowCombobox

        /// <summary>
        /// 
        /// </summary>
        /// <param name="lv"></param>
        /// <param name="lst"></param>
        /// <param name="x">鼠标的x坐标</param>
        /// <param name="y">鼠标的y坐标</param>
        /// <param name="col">ComboBox显示在哪个列上</param>
        /// <param name="defaultValueCol">ComboBox的默认值列</param>
        private static void ShowCombobox(ListView lv, ComboBox lst, int x, int y, int col, int defaultValueCol)
        {
            var item = lv.GetItemAt(x, y);
            if (item == null || !item.Checked)
                return;
            comboboxItem = item;

            int lWidth = 0, rWidth = 0;
            for (int i = 0; i <= col; i++)
            {
                int tmp = lv.Columns[i].Width;
                if (i < col)
                    lWidth += tmp;
                rWidth += tmp;
            }

            if (x > rWidth || x < lWidth)
            {
                lst.Visible = false;
                return;
            }

            //获取所在位置的行的Bounds            
            Rectangle rect = item.Bounds;
            //修改Rect的范围使其与第二列的单元格的大小相同,为了好看 ,左边缩进了2个单位                       
            rect.X += lv.Left + lWidth + 2;
            rect.Y += lv.Top + 2;
            rect.Width = rWidth - lWidth;
            lst.Bounds = rect;
            string val = item.SubItems[col].Text;
            if (string.IsNullOrEmpty(val) && defaultValueCol >= 0 && item.SubItems.Count > defaultValueCol)
                val = item.SubItems[defaultValueCol].Text;
            lst.Text = val;
            lst.Visible = true;
            lst.BringToFront();
            lst.Focus();
            lst.Name = col.ToString();

            //lst.SelectedIndexChanged -= lstSelectedIndexChanged;// (obj, args) => { MessageBox.Show("1"); };
        }
开发者ID:bincle,项目名称:Beinet.cn.Tools,代码行数:49,代码来源:MainForm.cs

示例2: GetMouseCol

        // 获取鼠标所在的列号
        private static int GetMouseCol(ListView lv, int x, int y, out int lWidth, out int rWidth)
        {
            lWidth = rWidth = 0;
            var item = lv.GetItemAt(x, y);
            if (item == null || !item.Checked)
                return -1;
            comboboxItem = item;

            for (int i = 0; i < item.SubItems.Count; i++)
            {
                int tmp = lv.Columns[i].Width;
                rWidth += tmp;
                if (x <= rWidth && x >= lWidth)
                    return i;

                lWidth = rWidth;
            }
            return -1;
        }
开发者ID:bincle,项目名称:Beinet.cn.Tools,代码行数:20,代码来源:MainForm.cs

示例3: listItem

        private void listItem(ListView listView, MouseEventArgs e)
        {
            ListViewItem item = listView.GetItemAt(e.X, e.Y);
            if (item != null)
            {

                item.Selected = true;
                var obj = new Popup();
                obj.textBox1 = item.SubItems[0].Text;
                obj.textBox2 = item.SubItems[1].Text;
                obj.textBox3 = item.SubItems[2].Text;
                obj.textBox4 = item.SubItems[3].Text;
                obj.textBox5 = item.SubItems[4].Text;
                obj.textBox6 = item.SubItems[5].Text;
                obj.textBox7 = item.SubItems[6].Text;
                obj.textBox8 = item.SubItems[7].Text;
                obj.textBox9 = item.SubItems[8].Text;
                obj.textBox10 = item.SubItems[9].Text;
                obj.recevoirListView();
                obj.ShowDialog();
                refresh();

            }

            else if ( item == null )
            {
                var obj = new Popup();
                obj.textBox1 = "Michaux";
                obj.textBox2 = "Samuel";
                obj.textBox3 = "[email protected]";
                obj.textBox4 = "0642958853";
                obj.textBox5 = "0642958853";
                obj.textBox6 = "71";
                obj.textBox7 = "Rue Jean Jacques Rousseau";
                obj.textBox8 = "59260";
                obj.textBox9 = "Hellemmes";
                obj.textBox10 = "Appartement 1";
                obj.recevoirListView();
                obj.ShowDialog();
                refresh();
            }
        }
开发者ID:kameleon83,项目名称:Annuaire,代码行数:42,代码来源:Annuaire.cs

示例4: getItemUnderMouse

        /// <summary>
        /// Returns the item in the given ListView under the cursor.
        /// </summary>
        private ListViewItem getItemUnderMouse( ListView list, int x, int y )
        {
            // Get the coordinates relative to the control.
            Point localPoint = list.PointToClient( new Point( x, y ) );

            return list.GetItemAt( localPoint.X, localPoint.Y );
        }
开发者ID:phillco,项目名称:LANdrop,代码行数:10,代码来源:MainForm.cs

示例5: GetListViewItemAt

        private ListViewItem GetListViewItemAt(ListView listView, Point pos)
        {
            // Returns the location of the mouse pointer in the ListView control.
            Point cp = listView.PointToClient(pos);

            // Obtain the item that is located at the specified location of the mouse pointer.
            return listView.GetItemAt(cp.X, cp.Y);
        }
开发者ID:timmersuk,项目名称:KSP-Mod-Admin-aOS,代码行数:8,代码来源:frmColumnSelection.cs


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