Hi,
I have a datagridview tied to a bindingsource and when I go to the new row on the grid I fire the AddingNew event on the bindingsource. This usually fires right when the user enters the row but it is not firing until the user enters a value in one of the cells and even then the defaults are not showing on the grid.
Your advice is appreciated and this is a pretty big deal for our applications.
Thanks, Tim
Hi Tim,
For the event firing issue, the row is only created after the first value is entered, this is by design, different from WinForms. We do this so the row is not recreated every time the user clicks on it and removed every time they click out of it. If you attach a solution demonstrating the behavior you’re trying to replicate with the event I can help find a workaround for it!
For the default value, it’s a known issue and I’m attaching a sample that you can use as a template and modify to get your desired behavior as a workaround. It’s a known bug and we’re working on the solution.
Let me know if this works for you!
Best regards,
Levie
Hi Ewan,
not sure if it helps in your case but in a similiar situation adding the following code to a customers project did fix that issue:
Attach to the ColumnChanging event of your DGV and add the following code in the event handler:
if (e.ProposedValue == null)
{
e.ProposedValue = DBNull.Value;
}
If that does not help, please send us more information/code that helps us to understand & reproduce that issue.
Best regards
Frank
I have a data bound DGV with and index column which cannot be null.
When I try
private void dgvTest_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
{
if (!isLoading && !isSaving)
{
//dgvTest[5, e.RowIndex].Value = 0;
e.Row[5].Value = 0;
}
}
Which fires after you add the first value to the row, effect of setting the default value is to create a second new row with the first row producing a null value error.
How do I get round this?
Please login first to submit.