I would recommend instead separating the button click into a method which you can then call
Edited to account for Compacted Framework.
Add a name property to your textBox
TextBox textBox = new TextBox() { Name = "the_textBox" ....
change your confirmation.Click to this
confirmation.Click += (sender, e) => { Confirmation_Click(prompt); };
add this method
private static void Confirmation_Click(Form prompt)
{
TextBox textBox = prompt.Controls.Find("the_textBox", false).FirstOrDefault() as TextBox;
if(textBox == null)
return; //uhm weird
bool k = IsValidPrice(textBox.Text);
if (k)
prompt.Close();
else
textBox.Focus();
}
Replace your KeyDown Method with this
private static void ModalForm_KeyDown(object sender, KeyEventArgs e)
{
Form form = sender as Form;
if(form == null)
return; //uhm weird
if (e.KeyData == Keys.Enter)
{
Confirmation_Click(form);
}
}