Problems encountered during project creation:
DataSource is referenced once by ComboBox, and the selected value will be remembered. The value will be directly displayed in ComboBox next time.
In order to verify whether dataSource or ComboBox contains the memory function, this experiment is set up,
Composition of the experiment:
1. The first ComboBox (hereinafter referred to as cbm1 and 4) in the second and third comboboxes (hereinafter referred to as cbm2, 3, 5, and 6) of the same row are dynamically assigned values.
2. The focus event exists in the DataGridView. The content of the Focus event is: select a focus, and the values of each cell in the row where the focus is located will be displayed on the ComboBox in the second row.
Tutorial steps:
1. When I select the DataGridView grid, the value of the row in which the focus is located is reflected in the ComboBox in the second row.
2. When I change the value of cbm4, cbm5 and cbm6 reference the value of dataSource.
3. Now I will change the value of cbm1. cbm2 and cbm3 reference the value of the same dataSource as cbm5 and cbm6.
4. As a result, the value of the row where the focus is located is reflected in the ComboBox in the second row. At the same time, the ComboBox in the first row shows an astonishing synchronization.
Conclusion:
When dataSource is used in the second row of ComboBox, and dataSource is used in the first row of ComboBox, the first row of ComboBox will display the value referenced by the second row of ComboBox in dataSource. Therefore, the memory is not the ComboBox itself, but the dataSource, and the "Memory" is a dynamic memory.
I have discussed this phenomenon of "dataSource memory" with a friend of C #. He said that the query of MSDN failed, but he said that if you do not like this memory function, N methods can be avoided. One of them is to use:
( item }
Demonstration video of the experiment:
Link: http://pan.baidu.com/s/1pJ2OTCn password: m5o4