打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
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; }    }}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
DEV GridControl小结。。
DevExpress用法总结大全
XtraGrid gridview基本用法
DevExpress学习系列(控件篇):GridControl的基本应用
dev经验
DevExpress Grid控件经典常用功能代码收集
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服