Re: treeView keydown

From: Ludovic SOEUR (Ludovic_SOEUR_at_hotmail.com)
Date: 03/24/05


Date: Thu, 24 Mar 2005 09:24:29 +0100

Nothing is wrong with your code. Enter key is already used for an other
control (for example, if you set an accetButton for your form). The solution
is to says to the control that Enter key is an input key.

To do so, override TreeView class like following :
    class TreeView2:TreeView {
         protected override bool IsInputKey(Keys keyData) {
              if (keyData==Keys.Enter) return true;
              return base.IsInputKey (keyData);
         }
    }

Note that if you want to catch other keys like TAB, you can use a switch
statement. And if you want to catch ALL keys, always return true in
IsInputKey method.

And do not forget to replace
    System.Windows.Form.TreeView tree;
par
    TreeView2 tree;

et de même
    tree=new System.Windows.Form.TreeView();
par
    tree=new TreeView2();

Hope it helps,

Ludovic Soeur.

"Hrvoje Voda" <hrvoje.voda@luatech.com> a écrit dans le message de
news:d1s0d7$bhv$1@ls219.htnet.hr...
> What is wrong in this code?
>
> private void tree_KeyDown(object sender, System.Windows.Forms.KeyEventArgs
> e)
>
> {
>
> if (e.KeyCode == Keys.Enter )
>
> {
>
> ConnString = "workstation id=HRV;packet size=4096;integrated
> security=SSPI;data source=HRV;persist security info=False;initial
> catalog=DVD Kolekcija";
>
> bDb = new Db(ConnString);
>
> grid.Refresh();
>
>
> grid.Table = bDb.datasetDVD.Tables ["DVD"];
>
> }
>
> }
>
>
>
> I press ENTER when I'm on treeview control but nothing happens!
>
>
>
> Hrcko
>
>