Link to home
Start Free TrialLog in
Avatar of tmajarov
tmajarov

asked on

Change text of databound textbox programatically not creating Proposed version of data

This is a little esoteric. I have a text box control (txtbox1) bound to a dataset.  I am setting the .text property programmatically based on user interaction with another control.  The text box is on a TabPage (tabpage1).  When I set the text programmatically, navigate to TabPage2, and then return to the TabPage1,  the textbox reverts to the original text.  After changing the text programmatically if I test for myDataSet.myTable(0).myrow(currentrow)("FieldName",DataRowVersion.Proposed) I get a message that there is no proposed value.
 If I type the change by hand  I return the new value as proposed, and I don't lose the new value between navigation of the tabspages.  I would like to get the programmatic value to set a proposed value so that I still have the option of rejecting the change to the dataset, without having to write my own sub to manage this.  
Any ideas how to get the programmed text the register as having changed?  I tried setting the .modified property to True this did not work.
Is there a way to work directly with the data set to set a value as proposed while maitaining a record of the original value?  
thanks in advance
Tom Majarov  
Avatar of NetPointer
NetPointer

If you BIND your dataset with your textbox instead of manually assigning the .text property, you will get your desired results.
Me.TextBox1.DataBindings.Add("Text",dataset.datatable,"FieldName")
Avatar of tmajarov

ASKER

Dear NetPointer,
The text box is bound - it displays an initial value from the dataset.  I am trying to edit the text, and the thereby the intial value from the dataset by passing a value derived from the another control, for example a listbox, to the text property of the text box.   I can change the value in the dataset directly: for example

mydataset.tables(0).rows(0)("myField") = myListBox.SelectedText  

- but this then become the current value in the dataset and cannot be undone with a cancelcurrentedit call against the bindingcontext for the table.  
ASKER CERTIFIED SOLUTION
Avatar of tmajarov
tmajarov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial