B
Barney
Hi,
This is my first query in google groups. I expect to don´t do it
wrong, and excuse me for my english, i haven´t used it for years...
I´m making a user component that inherits from a textbox. I would like
to use the acceptbutton property of its parent form when the "enter"
key is pressed. Something like that.
private void txtAutocomp_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Enter:
{
this.ParentForm.AcceptButton.PerformClick();
break;
}
}
}
The problem is that if the acceptbutton isn´t assigned it throws an
exception. I can put it like that, but it spends to much time till the
exception is thrown.
private void txtAutocomp_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Enter:
{
try
{
this.ParentForm.AcceptButton.PerformClick();
}
catch(Exception ex){};
break;
}
}
}
How can i know if the acceptbutton is assigned?
Thanks.
This is my first query in google groups. I expect to don´t do it
wrong, and excuse me for my english, i haven´t used it for years...
I´m making a user component that inherits from a textbox. I would like
to use the acceptbutton property of its parent form when the "enter"
key is pressed. Something like that.
private void txtAutocomp_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Enter:
{
this.ParentForm.AcceptButton.PerformClick();
break;
}
}
}
The problem is that if the acceptbutton isn´t assigned it throws an
exception. I can put it like that, but it spends to much time till the
exception is thrown.
private void txtAutocomp_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Enter:
{
try
{
this.ParentForm.AcceptButton.PerformClick();
}
catch(Exception ex){};
break;
}
}
}
How can i know if the acceptbutton is assigned?
Thanks.