本文整理汇总了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"); };
}
示例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;
}
示例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();
}
}
示例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 );
}
示例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);
}