设置网格的背景颜色 [英] Set the background colour of a grid
本文介绍了设置网格的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
是否可以根据数据中的值设置网格的背景颜色
?
我猜它很简单,但我一直无法确定
吧。
TIA
解决方案
你想要的是DataGrid对象上的BackColor属性。需要一个
颜色枚举
Color.Red例如
问候
-
-----------
有TidBits吗?
来这里: www.networkip.net/tidbits/default.htm
" John Doe" <一个******* @ discussions.microsoft.com>在留言中写道
news:0c **************************** @ phx.gbl ... < blockquote class =post_quotes>嗨
是否可以根据数据中的值设置网格的背景颜色?
我想这很简单,但我一直无法想了解它。
TIA
你想要的是DataGrid对象的BackColor属性。需要一个
颜色枚举
Color.Red例如
问候
-
-----------
有TidBits吗?
来这里: www.networkip.net/tidbits/default.htm
" John Doe" <一个******* @ discussions.microsoft.com>在留言中写道
news:0c **************************** @ phx.gbl ... < blockquote class =post_quotes>嗨
是否可以根据数据中的值设置网格的背景颜色?
我想这很简单,但我一直无法图吧
它。
TIA
你好Alvin
我只是在学习这个,我的网格有一个
DataTable作为源。
我创建了以下功能:
private void itemcreated(object sender,
DataGridItemEventArgs e)
{
if(((DataRowView).e.Item.DataItem ).ItemArray [5] .ToString
()==" 0")
{
e.Item.Cells [5] .BackColor = System.Drawing.Color.Red;
}
}
我已经指定数据网格应该使用当OnItemCreated被解雇时,这个
函数。
这给了我一个访问冲突,我猜测是因为我有一个DataTable作为源。
我认为
我在正确的轨道上,因为删除了if
语句按照我想要的颜色为红色。
TIA-----原始消息-----
你想要的是DataGrid
对象的BackColor属性。它需要aColor enum
Color.Red例如
问候
-
---------- -
获得TidBits?
在此处获取: www。 networkip.net/tidbits/default.htm
John Doe <一个******* @ discussions.microsoft.com>写在
messagenews:0c **************************** @ phx.gbl ...嗨
是否有可能根据数据中的值设置网格的背景颜色?
我想这很简单但是我已经无法
了它出来了。
TIA
。
Hi
Is it possible to set the background colour of a grid
based on a value in data?
I guess that it is simple but I have been unable to figure
it out.
TIA
解决方案
What you want is the BackColor property on the DataGrid object. It takes a
Color enum
Color.Red for example
regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits/default.htm
"John Doe" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...Hi
Is it possible to set the background colour of a grid
based on a value in data?
I guess that it is simple but I have been unable to figure
it out.
TIA
What you want is the BackColor property on the DataGrid object. It takes a
Color enum
Color.Red for example
regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits/default.htm
"John Doe" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...Hi
Is it possible to set the background colour of a grid
based on a value in data?
I guess that it is simple but I have been unable to figure
it out.
TIA
Hi Alvin
I am just learning this, I have a grid that has a
DataTable as the source.
I have created the following function:
private void itemcreated(object sender,
DataGridItemEventArgs e)
{
if(((DataRowView).e.Item.DataItem).ItemArray[5].ToString
() == "0")
{
e.Item.Cells[5].BackColor = System.Drawing.Color.Red;
}
}
I have then specified that the datagrid should use this
function when OnItemCreated is fired.
This gives me an access violation that I guess is due to
the fact that I have a DataTable as the source. I think
that I am on the right track since removing the if
statement colors the column red as I want.
TIA-----Original Message-----
What you want is the BackColor property on the DataGrid object. It takes aColor enum
Color.Red for example
regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits/default.htm
"John Doe" <an*******@discussions.microsoft.com> wrote in messagenews:0c****************************@phx.gbl...Hi
Is it possible to set the background colour of a grid
based on a value in data?
I guess that it is simple but I have been unable to figure it out.
TIA
.
这篇关于设置网格的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文