Two simple ways to accelerate DataGridView

Source: Internet
Author: User
Datagrid

DataGridView is easy to use, but if the amount of data is larger then there will be a performance problem. The general approach provided online is to accelerate through virtual mode. But sometimes, you can speed up DataGridView with simple settings.

(1) Use bound data. is to interact with Datagridview.datasource by loading the DataTable and then through BindingSource.

(2) Do not use Autosizecolumnsmode.allcells. If so, DataGridView will not be displayed until all the cells have been drawn. Because the width of the column is determined by the longest cell in the column. If you change to Displayedcells, you can determine the width of the column as long as the portion of the display is drawn.

(3) Where possible, use AutoGenerateColumns to derive from the dynamic set column.

In the practical application, a 10000*20 about the DataGridView, the original display efficiency is about 100s, using the above method became 6s. The effect is still more obvious.

Of course, if you want to accelerate the amount of data, you still need to use virtual mode. After all, the above method is only a temporary need.



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.