[Verification] C # dataSource Memory Function

Source: Internet
Author: User

 

 

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

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.