DataGridView:仅使用数字更改单元格的背景颜色 [英] DataGridView: change the background color of the cell with numbers only

查看:58
本文介绍了DataGridView:仅使用数字更改单元格的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用包含11列10行的datagridview。

我正在使用单元格点击事件:



I'm using datagridview having 11 columns and 10 rows.
I'm using cell click event:

if (dataGridView1[e.ColumnIndex, e.RowIndex].Style.BackColor == Color.Empty)
    dataGridView1[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Black;
else
    dataGridView1[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Empty;





它将新的背景颜色应用于所有11列,但我想将此代码仅应用于10列。

在我使用的最后11列中只有数字。



It applies the new backcolor to all 11 columns but I want apply this code only to 10 columns.
In the last 11th columns I use numbers only.

推荐答案

在单元格点击事件中添加此项检查



add this check in the cell click event

if(e.ColumnIndex<=10)
   {
     ////ur code shown in above question
   }





祝你好运; - )



good luck ;-)


这篇关于DataGridView:仅使用数字更改单元格的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆