M
Miro
My current headache is proper is with the datagridview
I am starting to realize that a DataGridView within vs2008 is not as
'robust' as a 'textboxfield' by default for example.
Example: A Textbox field can have masking, you can add easy validation and
so on.
Just adding a dummy datagridview to a form, databounding it, and allowing
editing works - but is not dummy proof.
For example: an integer bound to a column:
there is no way offhand to add a 'editmask' to the column, so right now I
must do this in the "CellValidating" event.
===
IF mydgv.Columns(e.ColumnIndex).Name = "txtANumber" Then
If Not IsNumeric(e.FormattedValue) Then
If e.FormattedValue.ToString = "" Then
e.Cancel = False
Else
e.Cancel = True
End If
Else
If e.FormattedValue.ToString <> CInt(e.FormattedValue).ToString Then
e.Cancel = True
End If
End If
End If
===
and do this for every field in there that is numeric and I expect just an
integer.
Otherwise, a user can type in ABC into the field, or a user can type in a
number as 1.1.1 and it will get an exception error.
I am looking for some good documentation - step by step somehwere as to how
to add parts to a datagrid view like an editmask or something. I am not
trying to create a 'complex' datagridview', just want to somehow properly
validate data.
Or am I missing something about validating data on a datagrid view. *** how
to properly errorcheck each field
One other thing I have found that is if I create a combobox on a field, the
list within the combobox must be the value in the field.
So I can't seem to create a textbox so a user can type in whatever they
want, and on the dropdown, let them pick from standard answers. The fill of
the dgv fails. -But thats a different story, I first have to learn how to
error handle
Thanks,
Miro
I am starting to realize that a DataGridView within vs2008 is not as
'robust' as a 'textboxfield' by default for example.
Example: A Textbox field can have masking, you can add easy validation and
so on.
Just adding a dummy datagridview to a form, databounding it, and allowing
editing works - but is not dummy proof.
For example: an integer bound to a column:
there is no way offhand to add a 'editmask' to the column, so right now I
must do this in the "CellValidating" event.
===
IF mydgv.Columns(e.ColumnIndex).Name = "txtANumber" Then
If Not IsNumeric(e.FormattedValue) Then
If e.FormattedValue.ToString = "" Then
e.Cancel = False
Else
e.Cancel = True
End If
Else
If e.FormattedValue.ToString <> CInt(e.FormattedValue).ToString Then
e.Cancel = True
End If
End If
End If
===
and do this for every field in there that is numeric and I expect just an
integer.
Otherwise, a user can type in ABC into the field, or a user can type in a
number as 1.1.1 and it will get an exception error.
I am looking for some good documentation - step by step somehwere as to how
to add parts to a datagrid view like an editmask or something. I am not
trying to create a 'complex' datagridview', just want to somehow properly
validate data.
Or am I missing something about validating data on a datagrid view. *** how
to properly errorcheck each field
One other thing I have found that is if I create a combobox on a field, the
list within the combobox must be the value in the field.
So I can't seem to create a textbox so a user can type in whatever they
want, and on the dropdown, let them pick from standard answers. The fill of
the dgv fails. -But thats a different story, I first have to learn how to
error handle
Thanks,
Miro