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: