Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. sub total a bindingsource with an array

sub total a bindingsource with an array

Scheduled Pinned Locked Moved C#
data-structuresquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    crash893
    wrote on last edited by
    #1

    I need to set up an array would look something like this but I'm not sure what type basicly i have a list of occrences lets say bob rob bob joe bob joe joe rob jay jay jay rob jay jay jay rob rob joe jay jay jay and from that I would have to "sub total" the list into something like this name count bob 3 rob 5 joe 4 jay 9 1) what type of array would this be 2) how would i prevent it from adding duplicate names?

    L 1 Reply Last reply
    0
    • C crash893

      I need to set up an array would look something like this but I'm not sure what type basicly i have a list of occrences lets say bob rob bob joe bob joe joe rob jay jay jay rob jay jay jay rob rob joe jay jay jay and from that I would have to "sub total" the list into something like this name count bob 3 rob 5 joe 4 jay 9 1) what type of array would this be 2) how would i prevent it from adding duplicate names?

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Any type of array would work and "you" could prevent it from adding duplicates by checking for the existence of it right? There are many different ways to do this, I would imagine you can find one of them yes? What course is this for?

      C 1 Reply Last reply
      0
      • L led mike

        Any type of array would work and "you" could prevent it from adding duplicates by checking for the existence of it right? There are many different ways to do this, I would imagine you can find one of them yes? What course is this for?

        C Offline
        C Offline
        crash893
        wrote on last edited by
        #3

        its not for a class its for something at work we have a db of incidents or tickets and each ticket has a type for example: Microsoft word or outlook or account lockout I make reports for my boss each month on how many of each we had but I am currently using excel for this which sucks so I'm trying to automate it ( or at least make an app he can run himself) I currently have it so that i can download it into a datagridview and filter it using bindingsource.filter but to graph it for him i would like to get totals and i also need to consolidate the names so that i can auto populate some of the combo boxes I just didnt know if there was a better way to "link" the cells in the array so that if I found bob I could +1 the bob total with out it getting misaligned

        L 1 Reply Last reply
        0
        • C crash893

          its not for a class its for something at work we have a db of incidents or tickets and each ticket has a type for example: Microsoft word or outlook or account lockout I make reports for my boss each month on how many of each we had but I am currently using excel for this which sucks so I'm trying to automate it ( or at least make an app he can run himself) I currently have it so that i can download it into a datagridview and filter it using bindingsource.filter but to graph it for him i would like to get totals and i also need to consolidate the names so that i can auto populate some of the combo boxes I just didnt know if there was a better way to "link" the cells in the array so that if I found bob I could +1 the bob total with out it getting misaligned

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          crash893 wrote:

          we have a db of incidents or tickets

          SQL can do subtotals

          crash893 wrote:

          its for something at work

          What do you do at work? Just curious.

          C 1 Reply Last reply
          0
          • L led mike

            crash893 wrote:

            we have a db of incidents or tickets

            SQL can do subtotals

            crash893 wrote:

            its for something at work

            What do you do at work? Just curious.

            C Offline
            C Offline
            crash893
            wrote on last edited by
            #5

            I thought about using the count feature in a query but the data is filtered at the binding source by the user and it would be "to hard" to run sql querys allot on the server that has this info. so i basically take one huge dataset add it to a binding source then filter it from there (what ever the user wants to see) then the idea is that they hit a button and it produces an array that goes into a graphing class and out pops a beautiful bar graph. usatoday I'm in IT but I'm not a programmer I'm just doing this for the fun / self education. I have so far something like (this is quasi sudo code) foreach (DataRowView view in myBindingSource) { If ( array.find((string)view["cat_name"] != 1) { array.add((string)view["cat_name"] ,1) // the ,1 is the total feild so im having some trouble with that } else "find index of catname and add +1 to the total" } return array

            C 1 Reply Last reply
            0
            • C crash893

              I thought about using the count feature in a query but the data is filtered at the binding source by the user and it would be "to hard" to run sql querys allot on the server that has this info. so i basically take one huge dataset add it to a binding source then filter it from there (what ever the user wants to see) then the idea is that they hit a button and it produces an array that goes into a graphing class and out pops a beautiful bar graph. usatoday I'm in IT but I'm not a programmer I'm just doing this for the fun / self education. I have so far something like (this is quasi sudo code) foreach (DataRowView view in myBindingSource) { If ( array.find((string)view["cat_name"] != 1) { array.add((string)view["cat_name"] ,1) // the ,1 is the total feild so im having some trouble with that } else "find index of catname and add +1 to the total" } return array

              C Offline
              C Offline
              crash893
              wrote on last edited by
              #6

              anyone?

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups