Fix an issue where DataGridView cannot display scroll bars in multiple threads

Source: Internet
Author: User

The original: Resolves an issue where DataGridView cannot display scrollbars in multiple threads

DataGridView specified DataSource to populate the data in multi-threading, when updating data, can cause DataGridView to appear suspended animation, display errors or scroll bar can not display the problem, In cases where the scrollbars setting of the DataGridView is guaranteed to both, the amount of data is greater than the range shown by the DataGridView, and there is no frozen column, the workaround is as follows:

One is to use Invoke to return the code that executes the data binding back to the main thread (because DataGridView is created by the main thread);

The second is to set the DataSource to null before specifying it.

Private Delegate void Invokehandler (); // in a child thread  this. Invoke (new Invokehandler (delegate()            {                null;                Datagridview1.datasource = Dgv_dt;            }));


Ignores the object created by the main thread of the sub-threading operation Just add one sentence: Control.checkforillegalcrossthreadcalls = false, but not in multi-threading.

Fix an issue where DataGridView cannot display scroll bars in multiple threads

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.