ObjectListView Treeview Get the selected treeview node Id

I have used objectlistview

TreeViewList

. I have a problem, I want to get the node id from my treeviewnode. i placed a contextMenuStrip1

when user right clicked. I am displaying the context menu bar. And I want this when the user clicks on this as unprotected. I want to get the Id value of the selected row in this image which 36993

. Below is the screen of my page. enter image description here

Below is the code to open context menu and click.

  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 which 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 solve it. thanks for your comments

+3


source to share


1 answer


You can already get the model object of the selected row in the handler CellRightClick

.

private MyModelType _ContextModel;

void treeListView1_CellRightClick(object sender, BrightIdeasSoftware.CellRightClickEventArgs e) {
    _ContextModel = e.Model as MyModelType;
    contextMenuStrip1.Show(Cursor.Position);
}

      



Then use _ContextModel

in your handler command1ToolStripMenuItem_Click

.

+2


source







All Articles