Jump to content


Action button on TreeView Control

- - - - -

  • Please log in to reply
2 replies to this topic

#1
bdmoore

bdmoore

    Task for the day: Think of interesting entry for here....

  • Members
  • PipPipPip
  • 196 posts
  • Gender:Male
  • Location:Swindon, UK
  • Devices:Touch Diamond, i780, TyTN II
Hi,

Can anyone tell me how to capture the action button being pressed for a TreeView control?  Neither the Click or KeyDown / KeyPress events seem to pick this up!

Cheers,

Ben


#2
komplex

komplex

    Newbie

  • Members
  • Pip
  • 17 posts
Click is not supported but AfterSelect is.

Try this code as an example. it requires a textbox and treeview to work of course.

private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
switch((e.Action))
   {
   case TreeViewAction.ByKeyboard:
      textBox1.Text = "Keyboard";
      break;
   case TreeViewAction.ByMouse:
      textBox1.Text = "Mouse";
      break;
   case TreeViewAction.Collapse:
      textBox1.Text = "Treview Collapsed";
      break;
   case TreeViewAction.Expand:
      textBox1.Text = "Treview Expanded";
      break;
   case TreeViewAction.Unknown:
      textBox1.Text = "Unknown";
   break;
   }
}



Terry


#3
bdmoore

bdmoore

    Task for the day: Think of interesting entry for here....

  • Members
  • PipPipPip
  • 196 posts
  • Gender:Male
  • Location:Swindon, UK
  • Devices:Touch Diamond, i780, TyTN II
Thanks for the response komplex :lol:

I got round the problem a different way - I used
OpenNetCFs ApplicationEx - it allows you to trap specific windows messages - something that MS should have included :D

cheers,

bdmoore





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users