Datagridview cell type conversion [memo], datagridview memo

Source: Internet
Author: User

Datagridview cell type conversion [memo], datagridview memo

After the column type is set, the column type of all the rows below the datagridview is the same as that of the Set column type.

When you need to change a cell in a row, you may encounter some problems and forget it again:

I used to solve this problem by referring to other people's blogs before. However, after a long time, when I encountered this problem again, I was stuck for a long time because I forgot how to deal with it from time to time, requirements to be displayed are as follows:

Reference: http://blog.csdn.net/hejialin666/article/details/4355858

 

 

Specific solution:

Maid dv = new maid (); maid [1]. cells [0] = dv; dataGridView1.Rows [1]. cells [1] = new maid (); // maid [1]. cells [2] = new maid (); maid [1]. cells [0]. value = true; dataGridView1.Rows [1]. cells [1]. value = false; dataGridView1.Rows [1]. cells [2]. value = "I raise the flag of text"; dataGridView1.Rows [1]. cells [0]. style. alignment = maid. middleCenter;

In fact, the most important thing is to specify the default value when converting cells, because the DataGridViewCheckBoxCell certainly only accepts bool type values, so after the conversion is complete, you must assign bool type values to cells; all columns in the example are of the DataGridViewTextBoxColumn type. Therefore, if you do not specify the convertible value for the cell after conversion, the following error is prompted:

 

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.