using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace ZB.QueueSys.Common { public class DataGridViewHelper { private static DataGridViewHelper instance; public static DataGridViewHelper Instance { get { if (instance == null) instance = new DataGridViewHelper(); return DataGridViewHelper.instance; } } public void SelectAllDgv(DataGridView dgv, string cellName, bool isChecked) { int count = dgv.Rows.Count; for (int i = 0; i < count; i++) { dgv.Rows[i].Cells[cellName].Value = isChecked; } } public void SetDgvRowColor(DataGridView dgv) { dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(204, 224, 233); } public void SetDgvRowColor(DataGridView dgv, Color color) { dgv.AlternatingRowsDefaultCellStyle.BackColor = color; dgv.AutoGenerateColumns = false; } public void SetDgvStyle(DataGridView dgv, Color color) { dgv.AlternatingRowsDefaultCellStyle.BackColor = color; dgv.AutoGenerateColumns = false; } /// <summary> /// 重绘DataGridView /// </summary> /// <param></param> /// <param></param> public void PaintDgv(DataGridView dgv, DataGridViewRowPostPaintEventArgs e) { try { SolidBrush b = new SolidBrush(dgv.RowHeadersDefaultCellStyle.ForeColor); e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), dgv.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 5, e.RowBounds.Location.Y + 4); } catch { return; } } } }
相关文章
- C# DataGridView控件 动态添加新行
- winfrom dataGridView 自定义分页实现
- C# DataGridView控件绑定数据后清空数据
- C# winfrom中的布局 控件Anchor和Dock的区别
- Winfrom设置DataGridView单元格获得焦点(DataGridView - CurrentCell)
- C# 怎样判断 datagridview 中的checkbox列是否被选中
- C# DataGridView中DataGridViewComboBoxCell列,下拉框事件的处理【完美解决】
- C#窗体控件DataGridView常用设置
- C# - VS2019 通过DataGridView实现对Oracle数据表的增删改查
- Redis总结(五)缓存雪崩和缓存穿透等问题 Web API系列(三)统一异常处理 C#总结(一)AutoResetEvent的使用介绍(用AutoResetEvent实现同步) C#总结(二)事件Event 介绍总结 C#总结(三)DataGridView增加全选列 Web API系列(二)接口安全和参数校验 RabbitMQ学习系列(六): RabbitMQ 高可用集群