RE: Different datatype in different rows
- From: v-lliu@xxxxxxxxxxxxxxxxxxxx (Linda Liu [MSFT])
- Date: Thu, 13 Sep 2007 09:49:52 GMT
Hi Paul,
Thank you for your reply!
In which eventhandler would you do it - I tried the RowsAdded but I'veseen that the first couple of rows added are empty
I mean you can add rows to the DataGridView when the form is loaded or when
you click a Button.
What do you mean by "the first couple of rows added are empty"?
Can you point me to any samples showing how to restrict the input in acell of type double.
You can subscribe the CellValidating event of the DataGridView and in the
event handler use the double.TryParse method to validate the input. For
example:
void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
double result;
bool isValid = double.TryParse(e.FormattedValue.ToString(), out
result);
if (!isValid)
{
e.Cancel = true;
}
}
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
.
- References:
- RE: Different datatype in different rows
- From: Linda Liu [MSFT]
- RE: Different datatype in different rows
- From: Paul S
- RE: Different datatype in different rows
- Prev by Date: Composite UserControl Not serializing all properties
- Next by Date: Try to solve a paint/flicker problem with user controls
- Previous by thread: RE: Different datatype in different rows
- Next by thread: RE: Nesting multiple layers of SubReporting (ReportViewer Control)
- Index(es):