Help doing simple math in a datagridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oceantrain
    New Member
    • Feb 2010
    • 11

    Help doing simple math in a datagridview

    I am new to C#. I have a datagridview with 9 columns. I am simply trying take the value in column 5 and subtract it from column 6. Then display the result in column 9. It seems simple enough.I know it's done in excel all the time. But I just cannot figure this out. Do I need to create a new class with a method called calculate columns? or does the datagridview class have something already built in that can handle this?
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    What do you already have? Did you already check the MSDN?

    Steven

    Comment

    • oceantrain
      New Member
      • Feb 2010
      • 11

      #3
      Steven,
      Thanks for the reply. I found this on MSDN


      But I have not yet tried to implement it. This task of calculating 2 columns and displaying the result in a 3rd column seems like it would be something that has been done many times before. But I just can't find the code to implement it.

      Comment

      • oceantrain
        New Member
        • Feb 2010
        • 11

        #4
        Originally posted by MrMancunian
        What do you already have? Did you already check the MSDN?

        Steven
        Steven,
        Thanks for the reply. I found this on MSDN
        Gain technical skills through documentation and training, earn certifications and connect with the community


        But I have not yet tried to implement it. This task of calculating 2 columns and displaying the result in a 3rd column seems like it would be something that has been done many times before. But I just can't find the code to implement it.

        Comment

        • stoogots2
          New Member
          • Sep 2007
          • 77

          #5
          Not sure if this is the most efficient, but I would create TemplateField in your GridView and override the RowCreated event to do the math.

          Comment

          Working...