| |

VerySource

 Forgot password?
 Register
Search
View: 797|Reply: 3

DataGridView super complicated problem, will come in to help

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Germany

Post time: 2020-1-17 14:40:01
| Show all posts |Read mode
The younger brother encountered the following problems while doing the system:

1. How to retrieve and display them in the DataGridView according to three conditions (that is, two textboxes and one DropDownList value).

2. How to add a row to the bottom of the DataGridView to count the sum of each column.

3. How to add a column, the value of this column is equal to the difference between the values ​​of the first two columns (ie, column 3 = column 2-column 1). When (column 2-column 1) <0 in a row, the value of column 3 in a row is 0; otherwise, the value of column 3 in a row (column 2-column 1).

4. When the DataGridView is paginated, it is set to 10 rows per page, but when the number of rows on a page is less than 10, the footer (where "previous page, next page" is displayed) is automatically disappeared. How to display it without displaying it " Previous Next".


All its required functions are shown in a simple table as follows:
. . . . . . . . . . . . . . . . . . .

Serial No. 1 2 3
1 3 19 16
     2 13 10 0
     3 8 20 12
     4 10 6 0
Total: 34 55 28

. . . . . . . . . . . . . . . . . .
     Previous Next

Please help how to achieve it, it is best to use C # to list the code. Thank you.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-23 08:54:01
| Show all posts
Bangding!
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-24 10:00:01
| Show all posts
You can refer to it!

            DataSet ds;
            ds = dbconn.selectSQL ();

            try
            {
                ds.Tables [0] .Columns [0] .ColumnName = "Serial Number";
                ds.Tables [0] .Columns [1] .ColumnName = "Column 1";
                ds.Tables [0] .Columns [2] .ColumnName = "Column 2";
                ds.Tables [0] .Columns [3] .ColumnName = "Column 3";

            int iNum1 = 0;
            int iNum2 = 0;
            int iNum3 = 0;
            for (int i = 0; i <dsTypes.Tables [0] .Rows.Count; i ++)
            {
                iNum1 = iNum1 + int.Parse (ds.Tables [0] .Rows [i] [1] .ToString ());
                iNum2 = iNum2 + int.Parse (ds.Tables [0] .Rows [i] [2] .ToString ());
                iNum3 = iNum3 + int.Parse (ds.Tables [0] .Rows [i] [3] .ToString ());
            }
            DataRow dr = ds.Tables [0] .NewRow ();
            dr ["Serial Number"] = "Total";
            dr ["column 1"] = iNum1;
            dr ["column 2"] = iNum2;
            dr ["column 3"] = iNum3;
            ds.Tables [0] .Rows.Add (dr);
            this.dataGridView1.DataSource = ds.Tables [0] .DefaultView;
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-24 10:54:01
| Show all posts
Points to note:
(1) If the serial number item must be of type string, it can be changed to "total".
(2) Column 1 is int!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list