Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Treeview/listfview item selection

Treeview/listfview item selection

Scheduled Pinned Locked Moved C#
csharpxmlquestioncareer
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vlusardi
    wrote on last edited by
    #1

    Using C# in a winform, I'm creating a file backup program that uses a treeview/listview pair, just like Windows Explorer, only exception is that all entries have checkboxes for selection... you make your selections and then save a backup file (in XML) containing a record of all dirs/files for that job. Works fine. In order to edit a saved job, the treeview/listview pair must be "re-hydrated", so that all selections for a given job are restored and the user can view and make changes. I know you can programmatically check/uncheck items, but I'd like to make the selections by sending mouse click messages, just as if I were making the selections for the first time with a mouse... can't use the "node.Check = true" method because it conflicts with my job creation logic. Is it possible to send mouse click messages programmatically...??? How is it done...? thanks very much.

    P 1 Reply Last reply
    0
    • V vlusardi

      Using C# in a winform, I'm creating a file backup program that uses a treeview/listview pair, just like Windows Explorer, only exception is that all entries have checkboxes for selection... you make your selections and then save a backup file (in XML) containing a record of all dirs/files for that job. Works fine. In order to edit a saved job, the treeview/listview pair must be "re-hydrated", so that all selections for a given job are restored and the user can view and make changes. I know you can programmatically check/uncheck items, but I'd like to make the selections by sending mouse click messages, just as if I were making the selections for the first time with a mouse... can't use the "node.Check = true" method because it conflicts with my job creation logic. Is it possible to send mouse click messages programmatically...??? How is it done...? thanks very much.

      P Offline
      P Offline
      Paresh Gheewala
      wrote on last edited by
      #2

      you can Invoke the tree's onmouseclick event with that when you fill the tree event object fill the node you want so as if it clicks on that item. Paresh;)

      V 1 Reply Last reply
      0
      • P Paresh Gheewala

        you can Invoke the tree's onmouseclick event with that when you fill the tree event object fill the node you want so as if it clicks on that item. Paresh;)

        V Offline
        V Offline
        vlusardi
        wrote on last edited by
        #3

        thanks for the reply... can you give me more info or an example of how I can send a mouseclick message to the treeview entry...??? thanks...

        P 1 Reply Last reply
        0
        • V vlusardi

          thanks for the reply... can you give me more info or an example of how I can send a mouseclick message to the treeview entry...??? thanks...

          P Offline
          P Offline
          Paresh Gheewala
          wrote on last edited by
          #4

          Ok Here is the code ;) what I tried !!! you can compile and run under shell by > csc Form1.cs > Form1 you can derive the TreeView Class and make protected method callable via making public and calling protected method. Hope this helps or gives hints to your stuff !!! ---------------------------- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WinTreeHandle { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private WinTreeHandle.Form1.MyTree treeView1; class MyTree : TreeView { public void OnMyAfterCheck(TreeViewEventArgs e) { e.Node.Checked = true; this.OnAfterCheck(e); } } private System.Windows.Forms.Button buttonClick; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; bool bLoading = true; public Form1() { bLoading = true; // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // bLoading = false; } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.treeView1 = new WinTreeHandle.Form1.MyTree(); this.buttonClick = new System.Windows.Forms.Button(); this.SuspendLayout(); // // treeView1 // this.treeView1.CheckBoxes = true; this.treeView1.ImageIndex = -1; this.treeView1.Location = new System.Drawing.Point(16, 24); this.treeView1.Name = "treeView1"; this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Node0"), new System.Windows.Forms.TreeNode("Node1"), new System.Windows.Forms.TreeNode("Node2"), new System.Windows.Forms.TreeNode("Node3"), new System.Windows.Forms.TreeNode("Node4")});

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups