Hi all,
I have encountered an issue I can't seem to find solution to.
I have a datagridview bound to a bindingsource
that bindingsource has AllowNew = True
I do the following in the bindingsources AddingNew event
'''---------------------------------------------------
Private Sub bs_AddingNew(ByVal sender As Object, ByVal e As
System.ComponentModel.AddingNewEventArgs) Handles bs.AddingNew
_addedItem = _mydata.NewItem
e.NewObject = _addedItem
_mydata.AddItem(_addedItem)
End Sub
'''----------------------------------------------------
The problem is when the user cancels the adding of the new row (escape-
key, or simply up-arrow without entering any data)
There doesn't seem to be an event to capture to reverse the manual
addition of the item to my underlying datasource (custom).
Does anyone have any suggestions?
Thanks in advance,
Steve
I did find a way out of the escape-key issue, see below, but not the
up-arrow no data issue!
Private Sub dgItems_RowStateChanged(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewRowStateChangedEventArgs) Handles
dgItems.RowStateChanged
If e.Row.State = DataGridViewElementStates.Visible AndAlso
e.Row.Visible = True Then
If _addedItem IsNot Nothing Then
_addedItem.Remove() 'Remove it from the underlying
datasource
_addedItem = Nothing
End If
End If
End Sub
--
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net