zoukankan      html  css  js  c++  java
  • gridView 练习

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication40
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
            {
    
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
                List<per> list = new List<per>();
                list.AddRange(new per[] { new per(1, "zwj2", DateTime.Now), new per(2, "zwj3", DateTime.Now), new per(3, "zwj4", DateTime.Now), new per(4, "zwj5", DateTime.Now), new per(5, "zwj6", DateTime.Now) });
                gridControl1.DataSource = list;
                gridView1.IndicatorWidth = 40;//
                gridView1.Columns[1].AppearanceCell.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                gridView1.Columns[1].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                // 设置标题居中
                gridView1.Columns[1].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridView1.Columns[0].AppearanceCell.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                gridView1.Columns[0].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridView1.Columns[0].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridView1.RowCellStyle += GridView1_RowCellStyle;
    
            }
    
            private void GridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
            {
                if (e.Column.FieldName == "times")
                {
                    e.Column.DisplayFormat.FormatString = "yyyy/MM/dd hh:mm:ss";
                }
    
            }
    
            private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
            {
                e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
                if (e.Info.IsRowIndicator)
                {
                    if (e.RowHandle >= 0)
                    {
                        e.Info.DisplayText = (e.RowHandle + 1) + "";
                    }
                    else if (e.RowHandle < 0 && e.RowHandle > -1000)
                    {
                        e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite;
                        e.Info.DisplayText = "G" + e.RowHandle.ToString();
                    }
    
                }
            }
        }
    
    
        public class per
        {
            public per(int id, string names, DateTime dt)
            {
    
                this.id = id;
                this.names = names;
                this.times = dt;
            }
            public int id { get; set; }
            public string names { get; set; }
            public DateTime times { get; set; }
    
        }
    
    }

     

  • 相关阅读:
    【资源共享】JNI 课题
    Firefly自动售货机解决方案
    【资源共享】Android开发技巧整理
    【资源共享】《Rockchip IO-Domain 开发指南 V1.0》
    【人脸识别+硬件】Firefly推出可商业化的人脸识别方案
    【技术案例】双目摄像头数据采集
    windows环境常用网络命令测试和分析(51cto实验01~02)
    利用三层交换机实现VLAN间路由配置
    c++11
    归并排序
  • 原文地址:https://www.cnblogs.com/xh0626/p/5935454.html
Copyright © 2011-2022 走看看