我试图在一个doubleclick对象中实现objectlistview函数。
开发人员认为,应该使用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
{
}
}发布于 2015-08-03 06:17:49
它为每个双击行提供一个值。但是我怎样才能从那一行得到细节呢?
我认为您必须使用下面这样的底层RowObject来访问OLVListItem:
private void treeListView_ItemActivate(object sender, EventArgs e) {
var item = treeListView.GetItem(treeListView.SelectedIndex).RowObject;
}发布于 2015-08-03 17:11:12
这就是我现在如何从树视图中获取数据的方法:
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
{
}
}https://stackoverflow.com/questions/31770863
复制相似问题