DataGridViewMaskedTextBoxColumn

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi again,
has anyone an idea on how i can get my datagrid view to only allow entry of
numeric values.

ok i can validate when leaving but what i really want to do is not allow
invalid characters to be typed to begin with.

Thanks for any help
Brian
 
Hi

Looks like you should handle KeyPressed event and filter our input there.
You can write handler rather for our DataGrid or for it's parent form.
 
Hi there,
thanks for your reply.
I finally broke the back of it anyways, i needed to add the keppress event
handler to the editfield.

dataGridView1.EditingControlShowing += new
DataGridViewEditingControlShowingEventHandler(dataGridView1_EditingControlShowing);

void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
dataGridView1.EditingControl.KeyPress += delegate(object
keyPressSender, KeyPressEventArgs keyPressArgs)
{
keyPressArgs.Handled = true;
Console.WriteLine(keyPressArgs.KeyChar.ToString());
};
}
 
Back
Top