private void pathTextBox_KeyPress(Object
sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
ReflectCurrentPathInTreeView();
}
}
Could any body explain why this code snippet doesn't work for me, i.e the ReflectCurrentPathInTreeView() method doesn't get called.
Sheva
-
-
footballism wrote:private void pathTextBox_KeyPress(Object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
ReflectCurrentPathInTreeView();
}
}
Could any body explain why this code snippet doesn't work for me, i.e the ReflectCurrentPathInTreeView() method doesn't get called.
Sheva
the "(char)13" bit doesn't make any sense.
-
I believe this is what you are looking for:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
treeView1.Nodes.Add(textBox1.Text);
}
}
(P.S. how come my code doesn't appear nice and color-coded? Is it an IE-only thing?)
-
BrianPeiris wrote:
(P.S. how come my code doesn't appear nice and color-coded? Is it an IE-only thing?)
Use code blocks:
[ code language="C#" ]
private void foo()
{
return;
}
[ /code ]
becomes
private void foo() { return; }
(take out the spaces after [ and before ])
-
And FYI, you'll probably want to handle the enter key so that you don't get a beep sound and it doesn't get passed down the chain. It only works in KeyDown not in Keypress or KeyUp so you'll have to use that event instead. (i.e. e.Handled = true)
-
John Galt wrote:And FYI, you'll probably want to handle the enter key so that you don't get a beep sound and it doesn't get passed down the chain. It only works in KeyDown not in Keypress or KeyUp so you'll have to use that event instead. (i.e. e.Handled = true)
John, thanks
Sheva
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.