tutorial with datagridview
-
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 :-)
-
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 :-)
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 :-)
-
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 :-)
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".
-
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 :-)
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;