Groups | Blog | Home
all groups > dotnet windows forms databinding > august 2004 >

dotnet windows forms databinding : Updating textbox and underlying currentrow.column at the same time ?


Fred Morin
8/21/2004 8:05:26 PM
I have a windows forms which has 2 editor controls.. A text box and a Combo

MyTextBox.Databindings.Add New Binding("value", "dsOrders",
"Orders.ContactName")

MyCombo.Databindings.Add New Binding("value", "dsOrders",
"Orders.CompanyId")

The Textbox is bound to the Contact Name and the Combo to a list of
company. Whenever I choose a company, I get the contact's name default
and I want to automatically update the content of the textbox. The user
could change that contact name also manually.

If I enter the text in the textbox, the current datarow is changed
automatically,

However, when I do that

myTextBox.value = ContactName 'form example

or

mytextBox.Text = ContactName


the datarow's ContactName is not modified, I have to use the following
line to modify it...

me.bindingcontext(dsOrders, "Orders").current.item("ContactName") =
ContactName

I assume this is not the best common practice and I would like to know
Miha Markic [MVP C#]
8/22/2004 8:56:17 AM
Hi Fred,

I would set the data to datasource directly.
Get the CurrencyManager, it will give you the current DataRow...

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

[quoted text, click to view]

Fred Morin
8/22/2004 9:11:14 AM
[quoted text, click to view]

I had tried that before and retried it this morning.. to no success,
until I called the CurrencyManager Refresh method after doing my update.

Worked like a charm :)

Thanks a lot

AddThis Social Bookmark Button