效果:

代码:

/// <summary>
/// 格式化数据
/// </summary>
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 3 ) //哪一列
{
if (Convert.ToInt32(e.Value) == 1)
{
e.Value="存在维修记录,双击查看!";
e.CellStyle.ForeColor = Color.Green;
}
else if(Convert.ToInt32(e.Value) == 0)
{
e.Value="未创建维修记录!";
e.CellStyle.ForeColor = Color.Red;
}
else { }
}
}

WinForm - 格式化DataGridView单元格数据的更多相关文章

  1. winform中dataGridView单元格根据值设置新值,彻底解决绑定后数据类型转换的困难

    // winform中dataGridView单元格在数据绑定后,数据类型更改困难,只能迂回实现.有时候需要将数字变换为不同的文字描述,就会出现int32到string类型转换的异常,借助CellFo ...

  2. winform的datagridview单元格输入限制和右键单击datagridview单元格焦点跟着改变

    在datagridview的EditingControlShowing事件里面添加代码: if (this.dgv_pch.Columns[dgv_pch.CurrentCell.ColumnInde ...

  3. [WinForm]- 设置DataGridView单元格内根据不同值显示图片

    首先设置要显示图片的列 DataGridViewImageColumn status = new DataGridViewImageColumn(); status.DisplayIndex = ; ...

  4. Winform Datagridview 单元格html格式化支持富文本

    Winform Datagridview 单元格html格式化支持富文本 示例: 源码:https://github.com/OceanAirdrop/DataGridViewHTMLCell 参考: ...

  5. WinForm笔记1:TextBox编辑时和DataGridView 单元格编辑时 的事件及其顺序

    TextBox 编辑框 When you change the focus by using the mouse or by calling the Focus method, focus event ...

  6. 【Winform-自定义控件】DataGridView 单元格合并和二维表头

    DataGridView单元格合并和二维表头应用: //DataGridView绑定数据 DataTable dt = new DataTable(); dt.Columns.Add("); ...

  7. DataGridView单元格合并

    本文章转载:http://www.cnblogs.com/xiaofengfeng/p/3382094.html 图: 代码就是如此简单 文件下载:DataGridView单元格合并源码 也可以参考: ...

  8. DataGridView单元格显示GIF图片

    本文转载:http://home.cnblogs.com/group/topic/40730.html DataGridView单元格显示GIF图片 gifanimationindatagrid.ra ...

  9. jqgrid设置单元格数据

    $("#gridid").jqGrid('setCell',rowid,icol,data); rowid为行ID,jqgrid内置的那个,从1开始 icol为列索引,从0开始, ...

随机推荐

  1. linux内核源码阅读之facebook硬盘加速利器flashcache

    从来没有写过源码阅读,这种感觉越来越强烈,虽然劣于文笔,但还是下定决心认真写一回. 源代码下载请参见上一篇flashcache之我见 http://blog.csdn.net/liumangxiong ...

  2. 一些常用的Intent及intent-filter的信息

    Uri Action 功能 备注 geo:latitude,longitude Intent.ACTION_VIEW 打开地图应用程序并显示指定的经纬度   geo:0,0?q=street+addr ...

  3. js设置奇偶行数样式

    $(document).ready(function () { odd = { "background": "none" }; //奇数样式 even = { ...

  4. 高性能网站优化-创建快速响应的Web

    <高性能网站建设进阶指南> 优化原则 优化的目的是希望降低程序的整体开销. 减少开销 通常认为开销就是程序的执行时间.而在进行优化工作时,应该把重点放在对程序开销影响最大的那部分. 假设我 ...

  5. 关于js闭包是否真的会造成内存泄漏(转载)

    闭包是一个非常强大的特性,但人们对其也有诸多无解.一种危言耸听的说法是闭包会造成内存泄露. 局部变量本来应该在函数退出的时候被解除引用,但如果局部变量被封闭在闭包形成的环境中,那么这个局部变量就能一直 ...

  6. Querying Microsoft SQL Server 2012 读书笔记:查询和管理XML数据 1 -使用FOR XML返回XML结果集

    XML 介绍 <CustomersOrders> <Customer custid="1" companyname="Customer NRZBB&qu ...

  7. wpf将表中数据显示到datagrid示例(转)

    原文:http://www.jb51.net/article/47120.htm 这篇文章主要介绍了wpf将表中数据显示到datagrid示例,需要的朋友可以参考下 a.在.xaml文件中拖入一个da ...

  8. 我的Python成长之路---第六天---Python基础(20)---2016年2月20日(晴)

    一.面向对象基础 面向对象名词解释: 类(Class): 用来描述具有相同的属性和方法的对象的集合.它定义了该集合中每个对象所共有的属性和方法.对象是类的实例. 类变量:类变量在整个实例化的对象中是公 ...

  9. 设计模式总结4--singleton pattern

    单例模式 保证每个类只有一个实例,并提供一个全局访问点 第一步 构造方法私有化第二步 公有化静态方法获取的实例 懒汉式  public class Bank{ private Bank(){} pri ...

  10. filezilla Can't open data connection.

    (000003)2016/7/4 9:31:42 - (not logged in) (10.61.41.57)> Connected, sending welcome message... ( ...