DataGridView常用设置

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 name="dgv">DataGridView dgv</param>
/// <param name="e">DataGridViewRowPostPaintEventArgs e</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; }
} /// <summary>
/// 设置DataGridView 外边框颜色
/// </summary>
/// <param name="dgv">DataGridView dgv</param>
/// <param name="e">PaintEventArgs e</param>
public void SetOuterBorderColor(DataGridView dgv,PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.Blue, new Rectangle(0, 0, dgv.Width - 1, dgv.Height - 1));
} }
}

  

  

C# Winfrom DataGridView常用设置的更多相关文章

  1. C#窗体控件DataGridView常用设置

    在默认情况下,datagridview的显示效果: 1.禁用最后一行空白. 默认情况下,最后一行空白表示自动新增行,对于需要在控件中进行编辑,可以保留 ? 1 dataGridView1.AllowU ...

  2. DataGridView常用属性和方法

    DataGridView常用属性: 只读属性设定    datagridview.ReadOnly = True 行自动追加    datagridview.AllowUserToAddRows = ...

  3. pycharm快捷键及一些常用设置

    pycharm快捷键及一些常用设置,有需要的朋友可以参考下. Alt+Enter 自动添加包 Ctrl+t SVN更新 Ctrl+k SVN提交 Ctrl + / 注释(取消注释)选择的行 Ctrl+ ...

  4. PLSQLDeveloper 常用设置

    PLSQL Developer常用设置及快捷键   1.登录后默认自动选中My Objects (已验证可用)   默认情况下,PLSQL Developer登录后,Brower里会选择All obj ...

  5. 百度编辑器UEditor常用设置函数大全

    在线文档对UEditor说明不够全面,收集了一些常用的方法和基本设置,以供参考.1.创建编辑器UE.getEditor('editor', { initialFrameWidth:"100% ...

  6. IntelliJ IDEA 常用设置讲解

    说明 IntelliJ IDEA 有很多人性化的设置我们必须单独拿出来讲解,也因为这些人性化的设置让我们这些 IntelliJ IDEA 死忠粉更加死心塌地使用它和分享它. 常用设置 IntelliJ ...

  7. pycharm快捷键、常用设置、包管理

    pycharm快捷键.常用设置.包管理 在PyCharm安装目录 /opt/pycharm-3.4.1/help目录下可以找到ReferenceCard.pdf快捷键英文版说明 or 打开pychar ...

  8. 《Pro Express.js》学习笔记——Express框架常用设置项

    Express 设置 系统设置 1.       无须再定义,大部分有默认值,可不设置 2.       常用设置 env view cache view engine views trust pro ...

  9. Source Insight 常用设置和快捷键大全

    Source Insight 常用设置和快捷键大全 退出程序 : Alt+F4 重画屏幕 : Ctrl+Alt+Space 完成语法 : Ctrl+E 复制一行 : Ctrl+K 恰好复制该位置右边的 ...

随机推荐

  1. laravel php门面模式

    门面模式   理解3个概念: 1)Container的概念,laravel所有的服务都注册在container里面,至于如何注册,就是使用service provider   2)service pr ...

  2. leetcode834 Sum of Distances in Tree

    思路: 树形dp. 实现: class Solution { public: void dfs(int root, int p, vector<vector<int>>& ...

  3. webstorm2017中添加git

    1.pc中先安装git 2.在webstorm中选择VCS -> Checkout from Version Control -> Git Git Repository URL:  [gi ...

  4. Available time

    Google Calendar, Outlook, iCal has been banned from your company! So an intrepid engineer has decide ...

  5. 了解 DML、DDL、DCL

    一.DML DML(Data Manipulation Language)数据操纵语言: 最经常用到的 SELECT.UPDATE.INSERT.DELETE. 主要用来对数据库的数据进行一些操作 S ...

  6. python学习-49 json模块

    json模块 --------将任何类型都转换为json字符串 方法dumps import json dic={"name":"abc"} data = js ...

  7. 20190924-LeetCode解数独题目分享

    解决数独 题目描述 编写一个程序,通过已填充的空格来解决数独问题. 一个数独的解法需遵循如下规则: 数字 1-9 在每一行只能出现一次. 数字 1-9 在每一列只能出现一次. 数字 1-9 在每一个以 ...

  8. 第五章:标准I/O库

    本章用于解析C语言标准I/O库,之所以在UNIX类系统的编程中会介绍C语言标准库,主要是因为UNIX和C之间具有密不可分的关系. 标准I/O库相比于操作系统的I/O库,具有更高的效率和可移植性,前者是 ...

  9. 十三、GPIO子系统

    由于之后的触摸屏驱动分析中使用到了GPIO子系统和i2c子系统,因此在分析触摸屏驱动之前我准备把这两个子系统进行简单分析. 之前我们使用GPIO引脚的方式并不是推荐的方式,当我们更改某一bit时,很有 ...

  10. TZOJ数据结构实验:左叶子之和

    int sumOfLeftLeaves(struct TreeNode* root) { if (root == NULL) { ; }//递归结束条件 if (root->left & ...