i have download objectlistview from this site http://objectlistview.sourceforge.net/cs/index.html
i am working with treelistview control from objectlistview project. i am working with treelistview DoubleClick event
and from there i am trying to capture selected item text and as well selected item immediate parent item text
i could successfully capture selected item text like this way from double click event
private void tvView_DoubleClick(object sender, EventArgs e)
{
ListView lv = (ListView)sender;
MessageBox.Show(tvView.FocusedItem.SubItems[1].Text);
}
now help me to capture the selected item immediate parent item text. here is the pic which help other to understand what i am trying to capture.
just see the image that i click on item or row whose immediate parent data 2
which i want to capture immediately. please guide me if any body worked with treelistview control. thanks
Using ObjectListView/TreeListView you should never use the underlying ListView itself or the ListViewItem objects. Read this
Using the TreeListView in comparison to the ObjectListView is a bit cumbersome.
Example (ignoring the double-click requirement):
private void tvView_SelectedIndexChanged(object sender, EventArgs e) {
// cast your TreeView to ObjectListView to access the selected Object
ObjectListView olv = sender as ObjectListView;
// get the selected child (you may want to check the type and if it really was a child that was selected here)
MyChildModelObject child = olv.SelectedObject as MyChildModelObject;
MyParentModelObject parent = _tvView.GetParent(child);
// ...
}
Since you did not mention the models, I assumed that you have two different model objects in your tree hierarchy (MyChildModelObject and MyParentModelObject).