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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:52:10+00:00 2026-05-10T19:52:10+00:00

In a DataGridView bound to a DataView, where cells in a column will contain

  • 0

In a DataGridView bound to a DataView, where cells in a column will contain one of two images from an ImageList (e.g. a green ‘online’ image or a red ‘offline’ image), how can you sum the number of occurences of each image when iterating through the DataGridView’s rows?

The Value and FormattedValue properties of DataGridViewImageCell return different references even though the entries in the underlying DataTable were created by referencing the same Image from the ImageList.

So rather than it counting 4 occurences of ‘online’ and 6 occurences of ‘offline’, I’m getting 10 occurences of alledgedly different images.

  • 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. 2026-05-10T19:52:10+00:00Added an answer on May 10, 2026 at 7:52 pm

    Given the description, the best I can suggest is to manually track the image key/index in the .Tag of the cell, and then run your distinct count on the .Tag. Alternatively, if you also have the data in a list/collection, count the data from the original source.

    [update following reply] Since the data is data-bound, you should be able to iterate the .Rows of the DataGridView, obtaining the .DataBoundItem of each. Then for each underlying object, you should be able to obtain the actual property value using TypeDescriptor:

            string propName = col.DataPropertyName;         // could also be a dictionary/hashset etc         // could be typed if you know the type         List<object> values = new List<object>();         foreach(DataGridViewRow row in dgv.Rows)         {             object obj = row.DataBoundItem;             // could be typed (via cast) if you know the type             object val = TypeDescriptor.GetProperties(obj)[propName].GetValue(obj);             if (!values.Contains(val))             {                 values.Add(val);             }         } 

    That any help?

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

Sidebar

Ask A Question

Stats

  • Questions 266k
  • Answers 266k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Tables are iffy (at least, in IE) when it comes… May 13, 2026 at 12:35 pm
  • Editorial Team
    Editorial Team added an answer Keep in mind that the string class is immutable. It… May 13, 2026 at 12:35 pm
  • Editorial Team
    Editorial Team added an answer There are number of ways to go here: Set up… May 13, 2026 at 12:35 pm

Related Questions

If you have a DataGridView that is bound to a DataView (someDataTable.DefaultView). ..and a
I am using the CellEndEdit event in DataGridView to detect when a user has
[Note : I've simplified my example for clarity] Let's say that I have a
I tried this ( http://brainof-dave.blogspot.com/2007/08/turning-off-auto-scrolling-in-bound.html ) in the RowChanged event on the DataTable that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.