Kenny Yu

Hi,

After binding a datatable to a datagridview and a textbox "Text" property, when I switch across record, the data pointer will change . . . .
However, how can I get the current data position back from the textbox

I found oDatagridview.BindingContext(oDataTable).Position is n-1 record which is the last binding index. I want n but not n-1.


Best regards,

Kenny



Re: Windows Forms Data Controls and Databinding Databinding of a Textbox

Vilsad - MCTS

http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx use this to know about databinding




Re: Windows Forms Data Controls and Databinding Databinding of a Textbox

Gavin Jin - MSFT

Hi,

First I will check my understanding with you, if there is any misunderstanding; feel free to let me know. You want to make your datagridview and textbox to the same datasourse ,but they do not synchronization.

So you can use two bindingcontext. If you have two BindingManagerBase objects (from two different BindingContext objects), you can set the Position properties of each BindingManagerBase to different values. This causes each set of data-bound controls to display different values from the same data source.

For more information, please check following article.

http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingcontext.bindingcontext(VS.80).aspx

And bindingcontext is count from 0 to n-1, you can do some change in your code.

If you have any further questions, feel free to let me know.

Best Regards

Gavin