Confused with EndCurrentEdit!!

T

touf

Hi,
What is the difference between theses expresions:
Me.BindingContext(myDataset.tables("myTable")).EndCurrentEdit()

Me.BindingContext(myDataset, "myTable").EndCurrentEdit()

I ask this question because sometime the first one works, and another time
it's the second that works
When do we have to use each one

Thanks
 
D

David Sceppa

Actually, the difference in behavior stems from the
BindingContext object. These two lines of code return different
objects:

BindingContext(myDataset.Tables("myTable"))
BindingContext(myDataset, "myTable")


Which syntax should you use? That depends on how you’ve
bound your controls.



If you use the following code to bind a DataGrid to a
DataTable:

myDataGrid.DataSource = myDataSet.Tables("myTable")

use similar syntax to access the
CurrencyManager/BindingManagerBase:

BindingContext(myDataset.Tables("myTable"))



Similarly, if you bind controls using the DataSource and
DataMember properties separately:

myDataGrid.DataSource = myDataSet
myDataGrid.DataMember = "myTable"

you would use the following syntax to access the
CurrencyManager/BindingManagerBase:

BindingContext(myDataset, "myTable")



When you bind TextBoxes at design-time, Visual Studio .NET
generates the following code:

myTextBox.DataBindings.Add("Text", myDataSet, _
"TableName.ColumnName")

which is equivalent to second syntax.


I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top