获取DatagridView中单元格的背景颜色 [英] Get the Background Color of a cell in a DatagridView

查看:350
本文介绍了获取DatagridView中单元格的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用VS2010 VB.NET,我有一个datagridview(dgv),我根据一定的值设置单元格的背景颜色。这个特定的单元格不存储任何信息,因此我不能使用该单元格中的数据来确定背景颜色。



我当前的尝试是完全失败并且MSDN只是特别设置而不是获得单元格的背景颜色。



代码我已经尝试了



Using VS2010 VB.NET, I have a datagridview (dgv) where I set the background color of cells according to a certain value. This particular cell does not store any information and therefore I can not use the data in that cell to determine the background color.

My current attempts are a complete failure and MSDN is only particular to "setting" and not "getting" the background color of a cell.

Code I've tried

if dgvNotes.Rows(clickedCell.RowIndex).Cells(1).Style.BackColor.ToString = "Red" then

if dgvNotes.Rows(clickedCell.RowIndex).Cells(1).Style.BackColor = Color.Red then





我无法找到有关该主题的更多信息,因为各个编码网站上的大多数帖子都专注于设置背景颜色。



有没有办法在填充dgv后确定单元格背景颜色?



谢谢



I am not able to find much information on the topic as most of the posts on various coding sites focusses on "setting" the background color.

Is there any way that I can determine cell background color after the dgv was populated ?

Thanks

推荐答案

Dim CellBkColor As System.Drawing.Color = dgvNotes.Rows(e.RowIndex).Cells(1).Style.BackColor
MsgBox(CellBkColor.ToString)





这是我正在寻找的解决方案。最初来自 http://stackoverflow.com/questions/ 23844778 / how-to-style-back-a-datagridview-cell [ ^ ]


这篇关于获取DatagridView中单元格的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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