DataGridView是一个比较常用的控件,下面用一个实例来介绍一下具体的使用过程。

     实例中是一个简单的管理学生信息的界面。如下:

DataGridView的用法

下面将从以下几个方面来介绍:

DataGridView的初始化
DataGridView与List实体的绑定;
DataGridView与DataTable的绑定;
DataGridView其他一些需要注意的地方;

 

DataGridView的初始化

     有几种方法可以进行初始化,第一种方法如下:

1: dgv.BorderStyle = BorderStyle.None;
   2:  
new DataGridViewImageColumn();
;
   5: imgCol.Image = Properties.Resources._2vgrid;
   6: imgCol.Width = 20;
   7: dgv.Columns.Add(imgCol);
   8:  
);
;
false;
  12:  
);
;
].Width = 120;
  16:  
);
;
].Width = 60;
  20:  
);
;
].Width = 120;
new DataGridViewCellStyle();
//N0代表不显示小数,因为MetaLength默认是decimal类型的,展示的时候,不需要显示小数位
null;
].DefaultCellStyle = dataGridViewCellStyle1;
  28:  
  29:  
);
;
].Width = 120;
  33:  
);
;
].Width = 100;

相关文章:

  • 2022-12-23
  • 2021-08-14
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
猜你喜欢
  • 2021-06-14
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案