Click here to Skip to main content
15,881,898 members
Home / Discussions / C#
   

C#

 
AnswerRe: Displaying Contents of an Array Pin
Luc Pattyn2-Jul-10 14:03
sitebuilderLuc Pattyn2-Jul-10 14:03 
QuestionClick here to send data to sever!! [modified] Pin
yum 20102-Jul-10 13:13
yum 20102-Jul-10 13:13 
AnswerRe: Click here to send data to sever!! Pin
Peace ON2-Jul-10 18:34
Peace ON2-Jul-10 18:34 
GeneralRe: Click here to send data to sever!! Pin
yum 20103-Jul-10 11:26
yum 20103-Jul-10 11:26 
QuestionAmazon API and C# Pin
tonyonlinux2-Jul-10 10:16
tonyonlinux2-Jul-10 10:16 
AnswerRe: Amazon API and C# Pin
Abhinav S2-Jul-10 17:57
Abhinav S2-Jul-10 17:57 
GeneralRe: Amazon API and C# Pin
tonyonlinux2-Jul-10 18:39
tonyonlinux2-Jul-10 18:39 
QuestionChange Row background color based by cell value Pin
grmihel22-Jul-10 5:14
grmihel22-Jul-10 5:14 
Hi all,


I have searched whole day now, for a solution that could fit my needs, yet again, I have to hope that some of your pro's here can help me getting closerto a solution.
I'm using DataGridView in C# WinForms to show 6 coloumns (CustomerName, Subscribers, unsubcribed, specialCases, potential, percentage connected in %), it would look like:

CustomerName	20	4	0	24	20/24*100=83%
CustomerName2	12	10	1	22	12/22*100=55%


etc.

And the rows just continue basedon the number of customers of cause. Now, thats ain't any problem, and I get all my data proper as wanted.
Now I want to make it a little bit more useful, and HIGHLIGHT every cell/row with a lightRed color, where the percentage is BELOW 70% (like row number 2 in my example).
I have try'd with:

private void grid_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            if (e.ListChangedType != ListChangedType.ItemDeleted)
            {
                DataGridViewCellStyle red = grid.DefaultCellStyle.Clone();
                red.BackColor = Color.LightPink;

                foreach (DataGridViewRow r in grid.Rows)
                {
                    if ((int)r.Cells["nummer6"].Value < 70)
                    {
                        r.DefaultCellStyle = red;
                    }
                }

            }
        }

or with a more similar code:

foreach (DataGridViewRow row in grid.Rows)
           {
               foreach (DataGridViewCell cell in row.Cells)
               {
                   if (cell.ColumnIndex == 5)
                   {
                       if ((int)cell.Value < 70)
                       {
                           row.DefaultCellStyle.BackColor = Color.LightPink;
                       }
                   }
               }
           }


But no matter what, then I can't get the backColor changed on rows where the % value in the last column cell is below 70%. Frown | :(

Any ideas and help are preciated....
AnswerRe: Change Row background color based by cell value Pin
Henry Minute2-Jul-10 7:07
Henry Minute2-Jul-10 7:07 
AnswerRe: Change Row background color based by cell value Pin
Henry Minute2-Jul-10 8:37
Henry Minute2-Jul-10 8:37 
GeneralRe: Change Row background color based by cell value [modified] Pin
grmihel25-Jul-10 0:43
grmihel25-Jul-10 0:43 
GeneralRe: Change Row background color based by cell value Pin
Henry Minute5-Jul-10 3:34
Henry Minute5-Jul-10 3:34 
GeneralRe: Change Row background color based by cell value Pin
grmihel26-Jul-10 3:27
grmihel26-Jul-10 3:27 
QuestionI want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 5:03
professionalNagy Vilmos2-Jul-10 5:03 
AnswerRe: I want a Clever Text Display Pin
R. Giskard Reventlov2-Jul-10 5:12
R. Giskard Reventlov2-Jul-10 5:12 
AnswerRe: I want a Clever Text Display Pin
OriginalGriff2-Jul-10 5:32
mveOriginalGriff2-Jul-10 5:32 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 5:46
professionalNagy Vilmos2-Jul-10 5:46 
AnswerRe: I want a Clever Text Display Pin
OriginalGriff2-Jul-10 5:33
mveOriginalGriff2-Jul-10 5:33 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 5:47
professionalNagy Vilmos2-Jul-10 5:47 
GeneralRe: I want a Clever Text Display Pin
OriginalGriff2-Jul-10 5:54
mveOriginalGriff2-Jul-10 5:54 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 7:14
professionalNagy Vilmos2-Jul-10 7:14 
AnswerRe: I want a Clever Text Display Pin
Luc Pattyn2-Jul-10 7:03
sitebuilderLuc Pattyn2-Jul-10 7:03 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 7:12
professionalNagy Vilmos2-Jul-10 7:12 
GeneralRe: I want a Clever Text Display Pin
Luc Pattyn2-Jul-10 7:20
sitebuilderLuc Pattyn2-Jul-10 7:20 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 10:53
professionalNagy Vilmos2-Jul-10 10:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.