One DataSource for multiple controls

后端 未结 4 683
孤独总比滥情好
孤独总比滥情好 2021-01-18 13:47

I have two ListBox in my winforms application, I assigne a datasource for both of them as follow:

private void MakeMeasurementUnits()
{
    var          


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-18 14:20

    Yes, this is normal behaviour. It happens because the ListView control uses a BindingSource object to track the currently selected item. (A List has no way to track a selected item without a BindingSource.)

    By default, a DataSource in a WinForms control uses a BindingSource created for it by the WinForms system itself.

    You can read more about the BindingSource at: http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx

    There is an article here which might help too: http://blogs.msdn.com/b/bethmassi/archive/2007/09/19/binding-multiple-comboboxes-to-the-same-datasource.aspx

提交回复
热议问题