C # An error occurred while displaying the UI when the thread changes the color of the DataGridview row.

Source: Internet
Author: User

Use Color. FromARGB () to obtain the Color when changing the Color of the DataGridView row. This method has three reloads, one of which makes the interface of the DataGridView

An exception is displayed.

Normal (use Color. Green mode and Color. FromArgb (int, int) Mode)

 

 

The interface displays an exception after the thread changes the Color of the DataGridView row (in Color. FromArgb (int) mode)

The non-thread mode uses Color. FromArgb (int) mode, and the interface still displays an exception.

 

Why?The temporary solution is to construct a Color object without using Color. FromArgb (int) in any case.

 

Main Code:

 

DataGridView1.Rows [I]. DefaultCellStyle. BackColor = Color. FromArgb (0x7800FF00); // The data list interface displays an exception in this way.
DataGridView1.Rows [I]. DefaultCellStyle. BackColor = Color. FromArgb (120,255,120); // use this method to display the data list interface as expected
// Maid [I]. DefaultCellStyle. BackColor = Color. Green;

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.