Click here to Skip to main content
14,661,186 members
Rate this:
Please Sign up or sign in to vote.
See more:
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.
Posted
Updated 21-Jan-13 1:16am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100