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

Related Questions

I am inserting a column in a DataGridView programmatically (i.e., not bound to any
How can I delete a line form a bound DataGridView when pressing the Delete
When the application is run, the DataGridView is bound to a DataTable . Later
With the DataGridView it is possible to display cells containing some long text. The
I populated a datagridview from a datatable. How do I read from the datagridview
DataGridView, for example, lets you do this: DataGridView dgv = ...; DataGridViewCell cell =
DataGridView.CellContentClick is not firing if I mouse click a DataGridViewCheckBoxCell very fast. How can
My DataGridView needs to support a number of types and these types may have
I have an editable DataGridView with SelectionMode set to FullRowSelect (so the whole row

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.