I used objectlistview
TreeViewList
. I have a problem, i want to get the node id from my treeviewnode. i placed a contextMenuStrip1
when user right click . i popup the the Context Menu strip.
And i want that when user click on this Like Not Secured . i want to get the selected row value Id in this picture that is 36993
. Below is the screen of my page .
Below is the code for my context menu open and click event .
treeListView1.CellRightClick += new EventHandler<BrightIdeasSoftware.CellRightClickEventArgs>(treeListView1_CellRightClick);
void treeListView1_CellRightClick(object sender, BrightIdeasSoftware.CellRightClickEventArgs e)
{
contextMenuStrip1.Show(Cursor.Position);
}
in this line of code i want to find the selected node id that is not working
private void command1ToolStripMenuItem_Click(object sender, EventArgs e)
{
// List<Node> _node = new List<Node>();
object obj = e.GetType();
object _node= this.treeListView1.SelectedObjects ;
}
also i try to find from this
private void command1ToolStripMenuItem_Click(object sender, EventArgs e)
{
int index = data.IndexOf((Node)treeListView1.SelectedObject)
}
what i am doing wrong in this code . How can i resolve it . Thanks for your comments
You could already fetch the model object of the selected line in the CellRightClick
handler.
private MyModelType _ContextModel;
void treeListView1_CellRightClick(object sender, BrightIdeasSoftware.CellRightClickEventArgs e) {
_ContextModel = e.Model as MyModelType;
contextMenuStrip1.Show(Cursor.Position);
}
Then use _ContextModel
in you command1ToolStripMenuItem_Click
handler.