Objectlistview doubleclick解释
我正在尝试在objectlistview
对象中实现doubleclick
函数。
根据开发人员的说法,应该使用ItemActivate
而不是MouseDoubleClick
。
所以我想出了这个:
private void treeListView_ItemActivate(object sender, EventArgs e) { try { ListView.SelectedIndexCollection col = treeListView.SelectedIndices; MessageBox.Show(col[0].ToString()); } catch (Exception e3) { globals.logfile.error(e3.ToString()); globals.logfile.flush(); } finally { } }
为每个双击行提供一个值。 但是如何从该行获取详细信息?
这是我现在使用的整个解决方案:
private void treeListView_ItemActivate(object sender, EventArgs e) { try { var se = (StructureElement)treeListView.GetItem(treeListView.SelectedIndex).RowObject; MessageBox.Show(se.id.ToString()); } catch (Exception e3) { globals.logfile.error(e3.ToString()); globals.logfile.flush(); } finally { } }
为每个双击行提供一个值。 但是如何从该行获取详细信息?
我认为您必须使用基础OLVListItem
访问OLVListItem
如下所示:
private void treeListView_ItemActivate(object sender, EventArgs e) { var item = treeListView.GetItem(treeListView.SelectedIndex).RowObject; }
这就是我现在从treelistview中获取数据的方式:
private void treeListView_ItemActivate(object sender, EventArgs e) { try { var se = (StructureElement)treeListView.GetItem(treeListView.SelectedIndex).RowObject; MessageBox.Show(se.id.ToString()); } catch (Exception e3) { globals.logfile.error(e3.ToString()); globals.logfile.flush(); } finally { } }