zoukankan      html  css  js  c++  java
  • C# Winfrom设置DataGridViewColumn标题对齐方式TitleAlignment

            private void Form1_Load(object sender, EventArgs e)
            {
                DataTable table = new DataTable("Student");
    
                DataColumn studentID = new DataColumn("studentID", typeof(string));
                table.Columns.Add(studentID);
    
                DataColumn studentName = new DataColumn("studentName", typeof(string));
                table.Columns.Add(studentName);
    
                DataColumn studentAmount = new DataColumn("studentAmount", typeof(decimal));
                table.Columns.Add(studentAmount);
    
                DataRow dr1 = table.NewRow();
                dr1["studentID"] = "2010092601";
                dr1["studentName"] = "张三";
                dr1["studentAmount"] = new decimal(3500.00);
    
                table.Rows.Add(dr1);
    
                DataRow dr2 = table.NewRow();
                dr2["studentID"] = "2010092602";
                dr2["studentName"] = "李四";
                dr2["studentAmount"] = new decimal(4000.00);
    
                table.Rows.Add(dr2);
    
                dataGridView1.DataSource = table;
                dataGridView1.Columns[2].Width = 150;
                dataGridView1.Columns[2].DefaultCellStyle.Format = "c";
                dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
                dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                dataGridView1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                dataGridView1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
                dataGridView1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }
  • 相关阅读:
    proxy
    javascript作用域链
    javascript技巧
    for of
    ES6模块与CommonJS模块有什么区别?
    DOM
    defer和async的区别
    浏览器如何解析css选择器?
    你是如何理解Vue的响应式系统的
    信息安全系统设计基础第十二周学习总结
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/2506698.html
Copyright © 2011-2022 走看看