• c# 设置datagridview样式


     //设置单元格自动宽
                datagridview.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                datagridview.DefaultCellStyle.ForeColor = Color.White;
                datagridview.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader;
                //设置字体大小
                System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
                dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                datagridview.RowsDefaultCellStyle = dataGridViewCellStyle1;
                datagridview.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
                
                datagridview.AutoGenerateColumns = false;
                //设置列填充满区域
                datagridview.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                datagridview.AllowUserToResizeColumns = false;
                datagridview.AllowUserToResizeRows = false;
    
                datagridview.BackImage = Image.FromFile(@"C:\Users\Administrator\Desktop\网格背景.jpg");
                //设置cell背景透明
                datagridview.ColumnHeadersDefaultCellStyle.BackColor = Color.Transparent;
                datagridview.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
                datagridview.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                //加上这句前面的才起作用
                datagridview.EnableHeadersVisualStyles = false;
    
                datagridview.DefaultCellStyle.BackColor = Color.Transparent;
                datagridview.DefaultCellStyle.ForeColor = Color.White;
                datagridview.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                datagridview.RowHeadersVisible = false;
                datagridview.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
    
                datagridview.ReadOnly = true;
  • 相关阅读:
    netty(4)高级篇-Websocket协议开发
    netty高级篇(3)-HTTP协议开发
    netty中级篇(2)
    netty入门篇(1)
    nio简介
    总账科目如何添加自定义属性?
    如何切换组织初次打开界面时,默认显示财务组织?
    超好用的免费Redis客户端
    Postman如何测试Webservice接口?
    创建Maven project 提示pom.xml 首行错误
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3044168.html
Copyright © 2020-2023  润新知