Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:55:04+00:00 2026-06-14T06:55:04+00:00

I am trying to get a datagrid to display different colour rows based on

  • 0

I am trying to get a datagrid to display different colour rows based on the quantity of the item.

The problem I’m having is the if statement:

if (RowType == < 5) 

is invalid, how do I parse the row type to be checked against a value?

foreach (DataGridViewRow row in dtaPart.Rows)
{
    //Cell three is where quantity is 
    string RowType = row.Cells[3].Value.ToString();

    if (RowType ==  //> 5)
    {
        row.DefaultCellStyle.BackColor = Color.White;
        row.DefaultCellStyle.ForeColor = Color.Black;
    }
    else if (RowType == //< 5)
    {
        row.DefaultCellStyle.BackColor = Color.Orange;
        row.DefaultCellStyle.ForeColor = Color.Black;
    }
    else if (RowType == //< 1)
    {
        row.DefaultCellStyle.BackColor = Color.Red;
        row.DefaultCellStyle.ForeColor = Color.Black;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:55:05+00:00Added an answer on June 14, 2026 at 6:55 am

    You can use double value = double.Parse(RowType) then check if value > 5, < 5, < 1 etc.

    However, if your datagrid column already contains a numeric type, like double or int, you don’t need to call ToString() and then parse the string; So instead of this:

    string RowTypeStr = row.Cells[3].Value.ToString(); 
    double RowType = double.Parse(RowTypeStr);
    

    but you can directly cast the value:

    double RowType = (double)row.Cells[3].Value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a heck of a time trying to get a silverlight datagrid to
im trying to display content of xmllistcollection in different fields in my datagrid however
I am trying to get the currently selected item of a datagrid that I
I'm trying to get a DataGrid to display the contents of an object[][] .
I'm trying to display a series of rows in a WPF DataGrid where each
I'm trying to get a basic datagrid for simple tabular input. The server will
im using the WPFToolkit's DataGrid and im trying to get an edit button working,
hello i'm trying to get the first value of a datagrid cell value but
I'm using a GridView and DataGrid. To use some JQuery I'm trying to get
I am trying to get a cell value from the selected item of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.