如何在DGV行上添加颜色 [英] How to put color on DGV row

查看:65
本文介绍了如何在DGV行上添加颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Microsoft Visual Studio 2005



如何根据内容将DGV行变成红色?

i有这个表:



名称ID已删除
charlotte 1 y
jay 1 n
rose 1 y
hale 1 y
mike 1 n





和此代码:

  Dim  a 作为 整数 =  0  
while a<> DGVpeople.RowCount

如果 DGVpeople.Rows(a).Cells( 2 ).Value = y 然后
' 使行变红的代码?
结束 如果
a = a + 1
结束
结束 < span class =code-keyword> Sub





怎么做'y'的行删除的列是否为红色?

解决方案

 对于 每个 As  DataGri dViewRow  DGVpeople.Rows 
如果 row.Cells( 2 )。值= y 然后
row.DefaultCellStyle.BackColor = Color.Red
结束 如果
下一步


应该

虽然<> DGVpeople.RowCount 



be

当a< DGVpeople.RowCount 





 DGVpeople.Rows(a).DefaultCellStyle.BackColor = Color.Red 


I am using Microsoft Visual Studio 2005

How do i make a DGV row color red depending on it's content?
i have this table:

   Name    ID    deleted
charlotte   1       y
   jay      1       n
   rose     1       y
   hale     1       y
   mike     1       n



and this code:

Dim a As Integer = 0
        While a <> DGVpeople.RowCount

            If DGVpeople.Rows(a).Cells(2).Value = "y" Then
                'Code to make the row red?
            End If
            a = a + 1
        End While
    End Sub



how do make the row of the ones with 'y' in the deleted column be color red?

解决方案

For Each row As DataGridViewRow In DGVpeople.Rows
	If row.Cells(2).Value = "y" Then
		row.DefaultCellStyle.BackColor = Color.Red
	End If
Next


Should

While a <> DGVpeople.RowCount


be

While a < DGVpeople.RowCount


and

DGVpeople.Rows(a).DefaultCellStyle.BackColor = Color.Red


这篇关于如何在DGV行上添加颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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