在数据网格视图中,明智地设置了&背面颜色 [英] In data grid view course wise set fore & Back color
问题描述
int value = Datagridviewcourse.Columns [ 课程]。索引;
{
if ( value == 2 )
{
e.CellStyle.BackColor = Color.Plum;
e.CellStyle.ForeColor = Color.Red;
}
}
当我运行数据网格视图前后颜色为红色和梅花时。
in数据库有不同的课程。
int value1 = Datagridviewcourse.rows [ REO]。index
{
if (value1 == 2 )
{
e.CellStyle.BackColor = Color.blue;
e.CellStyle.ForeColor = Color.black;
}
}
当我运行时显示错误如下;
'System.Windows.Forms.DataGridViewRowCollection.this [int]'的最佳重载方法匹配有一些无效的参数
参数'1':无法从'字符串转换'到'int'
以上两个错误显示在
int value1 = Datagridviewcourse.rows [REO]。index(this line)
我正在做的是数据库不同的课程都在那里。在所有课程中,在datagridview中有一些3到5个条目。基于数据网格视图的课程我指定特定的前和后颜色在数据网格视图中。
只有我写了上面的代码。
来自我的是什么错误。
帮助我。
int value1 = Datagridviewcourse.rows [ 跨度>REO]。index
I在这一行思考你面临的问题。在这里你提到的是位置而不是名字。
喜欢这个
int value1 = Datagridviewcourse.rows [ 0 ]。index
int value = Datagridviewcourse.Columns["Course"].Index;
{
if (value == 2)
{
e.CellStyle.BackColor = Color.Plum;
e.CellStyle.ForeColor = Color.Red;
}
}
when i run for data grid view fore and back color as red and plum.
in the data base different course are there.
int value1 = Datagridviewcourse.rows["REO"].index
{
if (value1 == 2)
{
e.CellStyle.BackColor = Color.blue;
e.CellStyle.ForeColor = Color.black;
}
}
when i run show the error as follows;
The best overloaded method match for 'System.Windows.Forms.DataGridViewRowCollection.this[int]' has some invalid arguments
Argument '1': cannot convert from 'string' to 'int'
the above two error shows in
int value1 = Datagridviewcourse.rows["REO"].index(this line)
what i am doing is in database different course are there.in all course there are some 3 to 5 entries in datagridview.based on the course in data grid view i assign for particular fore and Back color in data grid view.
for that only i written the above code.
from my what is the mistake.
help me.
Hi,
int value1 = Datagridviewcourse.rows["REO"].index
I think in this line you face the problem. Here you mentioned the position instead of name.
like this
int value1 = Datagridviewcourse.rows[0].index
这篇关于在数据网格视图中,明智地设置了&背面颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!