Krijn Posted January 22, 2003 Posted January 22, 2003 Hi, Does somebody know about this problem : I have two textbox controls witch I want to bind to my datasource (this contains only one row). I can edit the record (with beginEdit and EndEdit), but when I post 'rejectchanges' to the dataset the binding doesn't seem to affect the changes back to my textboxes. PS : When is the best time for setting BeginEdit. Do I have to set this in every Onclick event of my textboxes ? Thanks Quote
dusans Posted January 30, 2003 Posted January 30, 2003 You probably want to put back values from row back into text boxes!? To do this try : dim cm as system.windows.forms.currencymanager cm=me.bindingcontext(MyDataSet.Tables("MyDataTable")) cm.refresh() If it does not work try replacing bindingcontext call parameters with (MyDataSet,"MyDataTable") Quote
Krijn Posted February 7, 2003 Author Posted February 7, 2003 (edited) Thanks, But it is not working all the time. Problem : I have a dataset with 4 tables, 3 of them are only allowed to have maximum one single row. I've managed to use the currencymanager for single row tables but when I have to add a new row things go badly wrong. Situation: 1 textbox (txtone) In the Enter_event following code: Dim Mbase As BindingManagerBase = Me.BindingContext(Me.dsAanvraagdata, "Dossiers.labelpunt") If Mbase.Count = 0 Then Dim nrow As Rows.LabelpuntRow = _ Me.dsAanvraagdata.Labelpunten.NewLabelpuntRow nrow.SetParentRow(Me.dsAanvraagdata.Dossiers.DossierRow(0)) Me.dsAanvraagdata.Labelpunten.AddRow(nrow) Mbase.Position = 0 Dim cm As CurrencyManager = CType(Mbase, CurrencyManager) cm.Refresh() End If in Leave_event : Dim Mbase As BindingManagerBase = Me.BindingContext(Me.dsAanvraagdata.Tables("LabelPunten")) Dim cm As CurrencyManager = CType(Mbase, CurrencyManager) cm.EndCurrentEdit() When I enter and leave the textbox several times the text property clears itself although the text is saved in the dataset. The events of RowChanged are also not fired when I change the text. Greetings Edited February 7, 2003 by Robby Quote
Krijn Posted February 7, 2003 Author Posted February 7, 2003 (edited) Real code example Datasource : 3 dataTables Form : 3 textboxes, each binded to one datatable, + 2 buttons Merge doesn't work after clicking button2 ?? Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim System As New Aanvraagsystem() Dim tempds As New Aanvraagdata() tempds = System.GetbyDossierId(1) Me.dsAanvraagdata.Merge(tempds, False) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox3.DataBindings("Text").BindingManagerBase.EndCurrentEdit() If Me.dsAanvraagdata.GetChanges Is Nothing Then MessageBox.Show("False") Else MessageBox.Show("True") MessageBox.Show(Me.dsAanvraagdata.Labelpunten.LabelpuntRow(0).plaats) End If End Sub Private Sub TextBox3_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox3.Enter If TextBox3.DataBindings("Text").BindingManagerBase.Count = 0 Then TextBox3.DataBindings("Text").BindingManagerBase.AddNew() End If End Sub Please use tags [/vb ] around your code.[/color] Edited February 7, 2003 by Robby Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.