Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
DataTable control Binding issue
posted

Hi

I have problem with UltraTextEditor (and other Infra UI components building)

1. Component bound to same DataTable column (eg Name on below example) do not update
    Expected behavior - leaving tbName and focusing (eg tbCity) should result displaying same value in tbName2

2. Change made in components are not reflected in DataTable bound to eg dataGridView
    Expected behavior - leaving (moving focus) from currently edited control should update dataTable / grid

Cant believe this is Infra bug, I must be doing something wrong - appreciate your help here !

Below is sample app code and screen how it works

           DataTable dt = new DataTable();

           dt.Columns.Add("Name");
            dt.Columns.Add("City");


            tbName.DataBindings.Add ( "Value", dt, "Name",true, DataSourceUpdateMode.OnPropertyChanged);
            tbName2.DataBindings.Add( "Value", dt, "Name",true, DataSourceUpdateMode.OnPropertyChanged);
            tbCity.DataBindings.Add( "Value", dt, "City",true, DataSourceUpdateMode.OnPropertyChanged);


            // New row
            dt.Rows.Add ( dt.NewRow() );

            dataGridView1.DataSource = dt;

Parents
  • 469350
    Verified Answer
    Offline posted

    I tried this out and I don't think you can bind two controls to the same field like this. I first tested this out with the UltraTextEditor, and then I tried the Microsoft Textbox. And updating the Name TextBox does not update the Name2 TextBox in either case. So this seems to be an issue with how the DotNet BindingManager functions and is not related to the UltraTextEditor.

    The DataGridView DOES update in both cases.

    So then I checked the DataTable, and as long as the UltraTextEditor or TextBox has lost focus, the DataTable shows the changes I made. So I'm not sure why you are seeing different behavior. Or perhaps I misunderstsood what you are describing. Are you looking at the DataTable itself? Or are you calling GetChanges? GetChanges doesn't seem to show the changes until I either move to another row or explicitly call EndCurrentEdit on the BindingManager.

    I attached my sample project here so you can see if you get the same results. 


     WindowsFormsApp55.zip

Reply Children