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

  • SEARCH
  • Home
  • 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 6641057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:45:57+00:00 2026-05-25T23:45:57+00:00

Last week I started attempting to use Winforms to automate some reports. I am

  • 0

Last week I started attempting to use Winforms to automate some reports. I am not enjoying the transition (as simple as it may be to some of you)!

I am currently displaying data from a SQL view that I created using Oracle SQL Developer. I accecssed the data by using the DataGridView Tasks to select the table and display it (it seemed like the most straightforward method).

All of the data displays fine. However, I would now like to access the cells in the table. I want to be able to alter the colours of the cells based upon their values and to pull out some of the data if needs be.

To access the data and highlight the rows I was hoping to do something like this

protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        int theValue = Convert.ToInt32(e.Row.Cells[0].Text);

            if (theValue>0)
                e.Row.Cells[0].BackColor = System.Drawing.Color.Red
    }
}

It doesn’t work because the event is not firing. I think I am supposed to bind the data to my gridview but I have loaded all of the data through the designer. Is this the problem? I have no idea how to code it myself, I tried before but it threw a wobbly.

Furthermore, when I try to change the SQL query for the database through the designer it does not work. I think I am going to lose my mind at this rate!

  • 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-05-25T23:45:58+00:00Added an answer on May 25, 2026 at 11:45 pm

    You need to use the CellFormatting Event on the DataGridView like so

    private void MyGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
            {
                if ((int)MyGridView.Rows[e.RowIndex].Cells[0].Value > 30)
                {
                    e.CellStyle.BackColor = System.Drawing.Color.Red;
                    e.CellStyle.ForeColor = System.Drawing.Color.White;
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started doing jQuery last week, and so far I already made some
I'm new to C# (started last week) so be cool with me ;). I'd
I was writing some Unit tests last week for a piece of code that
I am currently getting first day Of this week and last week values with
By some coincidence this problem has come up twice in the last week. A
I just started using SVN as of last week (TortoiseSVN), is there any SVN
I am not a C programmer. I have just started reading K&R's TCPL last
I'm a student and just started learning C++ last week so this question is
I'm a complete newbee in php (started just last week) Issue is like this:
During last week I received some code and was asked to improve the performance.

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.