Click here to Skip to main content
15,883,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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.
C#
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;
XML
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.
Posted
Updated 21-Jan-13 1:16am
v2

1 solution

Hi,


C#
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

C#
int value1 = Datagridviewcourse.rows[0].index
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900