Main Topics
Browse All TopicsExperts, I am using C# (VS 2008). I have the following code; how do I change the value into color (for 2nd column) for a cell in DataGridView. Please advice.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you want get name of color that will be HARD TO REACH because color.name gives you name only if you create color like this: Colo.Red or Color.White.
When you use Color.FromARGB(123231) or Color.FromArgb(0, 0, 255); it will gives you something like this "ff0000ff".
If you want set background color of this cel into color from int then you must do this:
Cebik,
Yes 2nd column should be set to color specified. I made changes as per suggestion but it did not work. This is the code I have:
using System;
using System.Collections.Generic
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ThresholdValues
{
public partial class Form1 : Form
{
private int iCount;
public Form1()
{
InitializeComponent();
}
private void button1_Click_1(object sender, EventArgs e)
{
int i;
for (i = 1; i <= 10; i++)
{
iCount = iCount + 10;
switch (i)
{
case 1:
dataGridView1.Rows.Add(iCo
dataGridView1[1, i - 1].Style.BackColor = Color.FromArgb(255);
break;
case 2:
dataGridView1.Rows.Add(iCo
dataGridView1[1, i - 1].Style.BackColor = Color.FromArgb(16711935);
break;
case 3:
dataGridView1.Rows.Add(iCo
dataGridView1[1, i - 1].Style.BackColor = Color.FromArgb(16761087);
break;
case 4:
dataGridView1.Rows.Add(iCo
dataGridView1[1, i - 1].Style.BackColor = Color.FromArgb(65280);
break;
case 5:
dataGridView1.Rows.Add(iCo
dataGridView1[1, i - 1].Style.BackColor = Color.FromArgb(16776960);
break;
}
}
}
}
}
Please advice.
Thanks,
Shan
i've just checked this in vs2008 express..
and i don't have any problem
try my example app
http://www.speedyshare.
Business Accounts
Answer for Membership
by: CebikPosted on 2009-04-22 at 15:34:06ID: 24210353
i don't understand
this will help you?
Select allOpen in new window