本文整理汇总了C#中System.Windows.Forms.ListViewItem.GetSubItemAt方法的典型用法代码示例。如果您正苦于以下问题:C# ListViewItem.GetSubItemAt方法的具体用法?C# ListViewItem.GetSubItemAt怎么用?C# ListViewItem.GetSubItemAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ListViewItem
的用法示例。
在下文中一共展示了ListViewItem.GetSubItemAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeListView1
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);
}