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. tutorial with datagridview

tutorial with datagridview

Scheduled Pinned Locked Moved C#
tutorialdatabasehelpquestion
4 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.
  • S Offline
    S Offline
    simsen
    wrote on last edited by
    #1

    Hi, I have seach but can't find a tutorial, which shall do the following: I have a datagridview, which have 5 colomns - the first 4 I gets from a database. The 5. have I created as a unbound text. In each row I will use the 5. column to make a calculation on column 1 and 4 where I shall say: column4 = column1 * column4 In a textbox below the datagridview, I then will have that adds all the data in column5 Example: Column1.......Column2.....Column3......Column4......Column5 QTY...........Some text...Some text....Rate.........QTY*Rate 5.............aaa.........aaaa.........100..........500,00 2.............bbb.........bbbb.........150..........300,00 Textbox which contains the totally of Column5 = 800,00 Can anybody help me with a tutorial which contains these things? Kind regards, simsen :-)

    S 2 Replies Last reply
    0
    • S simsen

      Hi, I have seach but can't find a tutorial, which shall do the following: I have a datagridview, which have 5 colomns - the first 4 I gets from a database. The 5. have I created as a unbound text. In each row I will use the 5. column to make a calculation on column 1 and 4 where I shall say: column4 = column1 * column4 In a textbox below the datagridview, I then will have that adds all the data in column5 Example: Column1.......Column2.....Column3......Column4......Column5 QTY...........Some text...Some text....Rate.........QTY*Rate 5.............aaa.........aaaa.........100..........500,00 2.............bbb.........bbbb.........150..........300,00 Textbox which contains the totally of Column5 = 800,00 Can anybody help me with a tutorial which contains these things? Kind regards, simsen :-)

      S Offline
      S Offline
      simsen
      wrote on last edited by
      #2

      I try to explain me in another way; First, I make a mistake, not to say, I'm only familar with C#. Second, I don't know where to put the code - on which event it should occour. So I don't make the mistake again... I am using VS 2005. It's a Windows Form and I have added a new column on the datagridview. I need a function that calculates each row in the datagrid and shows the result on each row in the column I added and a function which calculates the column I have added and shows it in a textbox. Kind regards, simsen :-)

      S 1 Reply Last reply
      0
      • S simsen

        I try to explain me in another way; First, I make a mistake, not to say, I'm only familar with C#. Second, I don't know where to put the code - on which event it should occour. So I don't make the mistake again... I am using VS 2005. It's a Windows Form and I have added a new column on the datagridview. I need a function that calculates each row in the datagrid and shows the result on each row in the column I added and a function which calculates the column I have added and shows it in a textbox. Kind regards, simsen :-)

        S Offline
        S Offline
        spin vector
        wrote on last edited by
        #3

        I don't know if this will fully help but an excellent datagrid tutorial is on the CodeProject and written in 4 parts by Pete2004. Search for that, or for, "A Practical Guild to .NET DataTables, DataSets and DataGrids".

        1 Reply Last reply
        0
        • S simsen

          Hi, I have seach but can't find a tutorial, which shall do the following: I have a datagridview, which have 5 colomns - the first 4 I gets from a database. The 5. have I created as a unbound text. In each row I will use the 5. column to make a calculation on column 1 and 4 where I shall say: column4 = column1 * column4 In a textbox below the datagridview, I then will have that adds all the data in column5 Example: Column1.......Column2.....Column3......Column4......Column5 QTY...........Some text...Some text....Rate.........QTY*Rate 5.............aaa.........aaaa.........100..........500,00 2.............bbb.........bbbb.........150..........300,00 Textbox which contains the totally of Column5 = 800,00 Can anybody help me with a tutorial which contains these things? Kind regards, simsen :-)

          S Offline
          S Offline
          simsen
          wrote on last edited by
          #4

          I any should have the same question. The solution is: // Databinding for the Grid da2 = new OleDbDataAdapter("SELECT Ordre.Antal, Ordre.VareNr, Produkter.Varenavn, Produkter.PrisExMoms FROM Produkter INNER JOIN (Faktura INNER JOIN Ordre ON Faktura.FakturaID = Ordre.FakturaNr) ON Produkter.VareNr = Ordre.VareNr WHERE FakturaID=@fakid", cn); da2.SelectCommand.Parameters.Add("@fakid", OleDbType.Integer); da2.SelectCommand.Parameters["@fakid"].Value = fakid; //create datatable dtOrdrelinier = new DataTable(); //fill datatable da2.Fill(dtOrdrelinier); //create colum to hold the sum of other two colums DataColumn col = new DataColumn("RaekkeBeloeb"); col.DataType = typeof(System.Decimal); col.Expression = "Antal*PrisExMoms"; //add the colums dtOrdrelinier.Columns.Add(col); //Get the sum of the all totals txtBelob.Text = dtOrdrelinier.Compute("Sum(RaekkeBeloeb)", "").ToString(); //bind datatable to grid view dgrOrdre.DataSource = dtOrdrelinier;

          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