自定义DataGridview数据

自定义DataGridview数据
  private   void  setGyouseiCostDgvColName()
        {
            
this .dgvColName.Columns.Clear();
            
this .dgvColName.AutoGenerateColumns  =   false ;
            DataGridViewTextBoxColumn colName 
=   new  DataGridViewTextBoxColumn();
            colName.Name             
=   " 列名 " ;
            colName.HeaderText       
=   " 列名 " ;
            colName.DataPropertyName 
=   " 列名 " ;
            colName.DefaultCellStyle.Alignment 
=  DataGridViewContentAlignment.MiddleLeft;
            colName.ReadOnly         
=   true ;
            colName.Width            
=   160 ;

            
this .dgvColName.Columns.Add(colName);
            
this .dgvColName.Rows.Add( " a " );
            
this .dgvColName.Rows.Add( " b " );
            
this .dgvColName.Rows.Add( " c " );
            
this .dgvColName.Rows.Add( " d " );
            
this .dgvColName.Rows.Add( " e " );
            
this .dgvColName.Rows.Add( " f " );
            
this .dgvColName.Rows.Add( " g " );
            
this .dgvColName.Rows.Add( " h " );
        }







你可能感兴趣的:(自定义DataGridview数据)