You only want to display the custom fields in the database tutorial. Some fields are not displayed. This is also a small question ~~~~ The implementation is as follows:
1: add the number of columns to be displayed on the datagridview design page, and assign the corresponding name:
2: Write the background code to bind the data source. The data source is bound to a able. Set the attribute of the automatically created column of the datagridview to false.
View sourceprint? 1 dataset ds = userinfobll. getalllist ();
2 // cancel Automatic column creation for datagridview1
3 this. datagridview1.autogeneratecolumns = false;
4 this. datagridview1.datasource = ds. tables [0];
3: Direct the datapropertyname attribute of the columns added on the design interface to the corresponding columns to be displayed in the database. The implementation is as follows:
View sourceprint? 1 // bind the datapropertyname attribute of the Custom column to the column of the table in the database
2 this. datagridview1.columns ["column1"]. datapropertyname = ds. tables [0]. columns [0]. tostring ();
3 this. datagridview1.columns ["column2"]. datapropertyname = ds. tables [0]. columns [1]. tostring ();
4 this. datagridview1.columns ["column3"]. datapropertyname = ds. tables [0]. columns [3]. tostring ();