zoukankan      html  css  js  c++  java
  • WinForm DataGridView制作表格

    1、  将背景颜色改为白色

      this.dataGridView1.BackgroundColor = Color.White;

         或

      

    2、 禁止启用添加,启用编辑,启用删除

      this.dataGridView1.AllowUserToAddRows = false;

      this.dataGridView1.AllowUserToDeleteRows = false;

      this.dataGridView1.ReadOnly = true;

      或

      

      

    3、 禁止显示行标题的列

      this.dataGridView1.RowHeadersVisible = false;

        或

       

    4、 创建列,并绑定字段

       

      设置列宽:

       

      列标题居中,设置编辑,设置字体样式:

       

      

      文本内容居中,并设置字体:

       

      

    5、  禁止调整列,行的大小

       

      或

       

    6、  设置网格线

      //取消视觉样式

       

      //设置网格线样式和颜色

       

       

       

       

           //如果不需要滚动条可以在这里设置

       

       //取消DataGridView边框

      

           //让列宽,行自适应

      

     最后绑定数据源,运行效果如下:

      

  • 相关阅读:
    Valid Parentheses
    3Sum
    泛型(一)
    Longest Common Prefix
    Roman to Integer
    Integer to Roman
    Container With Most Water
    知道创宇研发技能表v2.2
    anti-dns pinning 攻击
    dominator
  • 原文地址:https://www.cnblogs.com/haibing0107/p/7468533.html
Copyright © 2011-2022 走看看