Hi Nabil,
I don't have any articles to point you to. It is from messages posted by others and recommendations by Microsoft for the binding classes. I have also run into a few "issues" in the past with working with them.
Your code provided looks good.
>Do you have any articles regarding the bugs of using BindingContext object?
>What is the best practice of using the methods on the DataTable on a form that contains a binded controls?
>
>I tried the following for adding a new record:
>Dim NewRow As DataRow = myDataTable.NewRow()
>Dim i, j As Int16
>i = myDataTable.Columns.Count - 1
>For j = 0 To i
> If Not myDataTable.Columns(j).AllowDBNull Then
> NewRow(j) = 0
> End If
>Next
>myDataTable.Rows.Add(NewRow)
>
>IS IT OK?
>
>
>>Hi Victoria,
>>
>>I would recommend using the methods on the DataTable itself instead of the BindingContext object. There are some known bugs that can cause inconsistencies with the CurrencyManager to add and cancel changes.
>>
>>>I want to add new record to my dataset.
>>>
>>>I'm confused, should I use
>>>myDataTable.NewRow()
>>>OR
>>>Me.BindingContext(myDataSet, myMainDataTable).AddNew()
>>>
>>>Also what to use to cancel the newly added record?
>>>myDataTable.RejectChanges()
>>>OR
>>>Me.BindingContext(myDataSet, myMainDataTable).CancelCurrentEdit
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi