private void Form1_Load(object sender, EventArgs e)         {             string str = "server=192.168.100.222;user=sa;pwd=p@ssw1rd;database=pwd1";             SqlConnection mycon = new SqlConnection(str);             try             {                 mycon.Open();                 DataSet mydt = new System.Data.DataSet();//建立填充数据库                 SqlDataAdapter mydpt = new SqlDataAdapter("select * from book",mycon);//建立适配器                 mydpt.Fill(mydt);                 dataGridView1.DataSource = mydt.Tables[0];//数据源绑定的是表不是数据库,所以要指定表,索引值从0开始  说明book这个表是数据库中第一个表

for (int i = 0; i < dataGridView1.Rows.Count; i++)                 {                     if (i % 2 == 0)                     {                         this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Beige;                     }                     else                     {                         this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;                                         }                 }                  //第二种方法                 this.dataGridView1.RowsDefaultCellStyle.BackColor = Color.Red;//DataGridView行单元格默认颜色                 this.dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Violet;//奇数行单元格默认颜色

}             catch (Exception ex)             {

MessageBox.Show(ex.Message);             }             finally             {                 mycon.Close();                         }         }

change color1的更多相关文章

  1. 代码的坏味道(10)——发散式变化(Divergent Change)

    坏味道--发散式变化(Divergent Change) 发散式变化(Divergent Change) 类似于 霰弹式修改(Shotgun Surgery) ,但实际上完全不同.发散式变化(Dive ...

  2. [LeetCode] Coin Change 硬币找零

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  3. input事件与change事件

    输入框的change事件: 必须等到输入框失去焦点的时候才会触发,鼠标在空白的地方点一下: 输入框的input事件: 在输入内容变化的同时,实时的触发,不需要等到失去焦点.

  4. Change the Target Recovery Time of a Database (SQL Server) 间接-checkpoints flushcache flushcache-message

    Change the Target Recovery Time of a Database (SQL Server) 间接checkpoints   flushcache flushcache-mes ...

  5. Change Line Type in OpenCascade

    Change Line Type in OpenCascade eryar@163.com 关键字KeyWords:OpenCascade,Line Aspect, Line Type 在OpenCa ...

  6. 华硕笔记本U盘启动系统/WinPE报错。Windows failed to start. A Recent hardware or software change might be the cause.

    最近在整一台华硕笔记本,大概有5年寿命了吧,质量还行,由于系统出了问题,打算用自制U盘WinPE进去修复一下.按照个人经验,在主板设置里启用了USB启动选项,并且设置USB启动顺序为第一个,可是进系统 ...

  7. You cannot change a partition into an extended one or vice versa Delete it first

    在Linux扩展LVM时,使用fdisk创建分区时,在磁盘上新建扩展分区(逻辑分区),修改分区格式,指定分区类型为8e时,报错"You cannot change a partition i ...

  8. [WPF系列]基础 Listening to Dependency Property change notifications of a given Element

    I want to share this great post from Anoop that shows a easy way to add a notification system to dep ...

  9. 鼠标的change事件

    原本想着在<input>输入输入框中添加change事件,来实现对输入内容的限定. 当人们在使用时跟多的会直接去点击完成.所以完成按钮的点击事件会和change事件产生 冲突,所以我把验证 ...

随机推荐

  1. 搭建ldap自助修改密码系统--Self Service Password

    系统版本:centos6 Self Service Password版本:1.1 服务安装: 安装依赖:yum install php70-ldap.x86_64 -y (版本尽量大于5.3,否则会提 ...

  2. svg动态添加小人

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  3. 神秘的.user.ini文件

    原文链接:https://segmentfault.com/a/1190000011552335

  4. ​DL_WITH_PY系统学习(第3章)

    本节提示: 1.DL的核心构建 2.Keras的简单介绍 3.搭建DL机器训练环境 4.使用DL模型解决基础问题 3.1 DL的基本构建:layer layer的定义:以1个或多个tensor作为输入 ...

  5. bzoj 1420 Discrete Root - 原根 - exgcd - BSGS

    题目传送门 戳我来传送 题目大意 给定$k, p, a$,求$x^{k}\equiv a \pmod{p}$在模$p$意义下的所有根. 考虑模$p$下的某个原根$g$. 那么$x  = g^{ind_ ...

  6. Codeforces 822C Hacker, pack your bags! - 贪心

    It's well known that the best way to distract from something is to do one's favourite thing. Job is ...

  7. [error] 2230#2230: *84 client intended to send too large body: 1711341 bytes

    centos7 lnmp部署知乎上传主体报错 2019/01/17 18:55:27 [error] 2230#2230: *89 open() "/code/wordpress/favic ...

  8. Apache下的ArrayUtils工具类总结

    ArrayUtils中的方法: 1.add():将给定的数据添加到指定的数组中,返回一个新的数组. 2.addAll():合并两个数组. 3.contains():检查该数据在该数组中是否存在,返回一 ...

  9. Android O HIDL的实现对接【转】

    本文转载自:https://blog.csdn.net/gh201030460222/article/details/80551897 Android O HIDL的实现对接1. HIDL的定义1.1 ...

  10. Selenium Webdriver 自动化测试开发常见问题(C#版)

    转一篇文章,有修改,出处http://www.7dtest.com/site/blog-2880-203.html 1:Selenium中对浏览器的操作 首先生成一个Web对象 IWebDriver ...