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
I would step through the code, and see if an exception is thrown
anywhere. If an exception is thrown, it will be swallowed by the code
calling your event handler, and do nothing.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Hrvoje Voda" <hrvoj...@luatech.com> wrote in message
news:d1s0d7$bhv$1...@ls219.htnet.hr...
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" <hrvoj...@luatech.com> a écrit dans le message de
news:d1s0d7$bhv$1...@ls219.htnet.hr...
Hrcko
"Ludovic SOEUR" <Ludovi...@hotmail.com> wrote in message
news:OvXvktEM...@TK2MSFTNGP10.phx.gbl...
Ludovic Soeur.
"Hrvoje Voda" <hrvoj...@luatech.com> a écrit dans le message de
news:d1tv3d$oe2$1...@ss405.t-com.hr...
Hrcko
"Ludovic SOEUR" <Ludovi...@hotmail.com> wrote in message
news:%236llvmF...@TK2MSFTNGP14.phx.gbl...
"Hrvoje Voda" <hrvoj...@luatech.com> a écrit dans le message de
news:d1u8ti$cno$1...@ss405.t-com.hr...
in constructor :
treeKolekcija.KeyDown += new KeyEventHandler(tree_KeyDown) ;
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 put your code into my user control :
protected override bool IsInputKey(Keys keyData)
{
if (keyData==Keys.Enter) return true;
return base.IsInputKey (keyData);
}
"Ludovic SOEUR" <Ludovi...@hotmail.com> wrote in message
news:Oi5b1CHM...@tk2msftngp13.phx.gbl...
namespace MonNameSpace {
public class MyUserControl : UserControl {
....
....
TreeView2 treeKolekcija;
....
....
....
private void InitializeComponent() {
...
...
this.treeKolekcija = new TreeView2();
...
...
}
...
...
private void tree_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e) {
...
your code
...
}
...
...
}
class TreeView2:TreeView {
protected override bool IsInputKey(Keys keyData) {
if (keyData==Keys.Enter) return true;
return base.IsInputKey (keyData);
}
}
}
Of course, if you have already overloaded TreeView Class, do not extend
TreeView2 from TreeView but from your own TreeView class.
Hope it helps...
If it does not, I would send you a complete example.
Ludovic Soeur.
"Hrvoje Voda" <hrvoj...@luatech.com> a écrit dans le message de
news:d20hbk$pra$1...@ss405.t-com.hr...