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 7759955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:45:25+00:00 2026-06-01T13:45:25+00:00

i am writing a viewer using datagridview to load a text file and display

  • 0

i am writing a viewer using datagridview to load a text file and display an m row x n column table (the table is editable by the user).

the main aim of this viewer is to change the backcolor of the max in each column to red, and the min of each column to green, and also cells that exceeds a certain threshold to pink. (i use a button to trigger the checkMinMax() method, which iterates through each column of the dataTable to extract lists of rows for min/max/exceed )

i am able to do this when i first load the data into the datatable. however, when i sort the datagridview and call the checkMinMax() again, the color is still fixed at the old position.

public void setCellBackColor (List<int> rows, int col, Color color)
{
    foreach (int row in rows)
    { 
        dataGridView_data.Rows[row].Cells[col].Style.BackColor = color;  
    }
}

i understand that i am using the index of the datatable rather than the rowId of the datagridview. so my question is if there is a way to map my datatable’s index to the rowId?

or is there a better way to do what i want to do ?

  • 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-01T13:45:27+00:00Added an answer on June 1, 2026 at 1:45 pm

    Just recall your setCellBackColumn after sorting your data. Row highlighting is not dynamic, so you have to recall it. You may do so by using the Sorted event of the grid. Don’t forget to specifically set the default color as white so it doesn’t keep the outdated colors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm writing text viewer for the iPhone using Core Text. Every time
I am writing a simple photo viewer in C++ using gtkmm and I can
I'am writing with my friends a simple photo viewer in C++ using gtkmm. Everything
I'm writing a c++ webcam viewer using video4linux. I need a RGB24 output (interleaved
I'm planning on writing a simple text viewer, which I'd expect to be able
I've been writing my user interface directly instead of using the Qt UI design
I am writing a book viewer that dynamically loads content as the user scrolls
Using HTML5 File API I am able to read text and XML files without
I am successfully writing to an Excel file, using javascript from my FireFox extension.
I've been writing some small maintenance/viewer tools that each connect to a SQLServer (2005)

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.