hi, I want to add the value data in datagridview of this code;
int tsp;
double mf, tcp, interest, disc;
int a, b;
double MP;
if (comboBox1.Text == "Deferred Cash Payment in 2 years at 0% interest")
{
a = int.Parse(textBox3.Text);
b = int.Parse(textBox4.Text);
tsp = a * b;
mf = tsp * 0.07;
tcp = mf + tsp;
label8.Text = tcp.ToString("₱000,000.00");
MP = tcp / 24;
the MP variables has a data; and i want to show it in datagridview with looping statement with 24 rows. and i want the output like this:
ex.
Days Amount
1 10,000
2 10,000
3 10,000
4 10,000
5 10,000
..
24 10,000
In windows forms application you can create a new DataTable instance and bind that DataTable to DataGridView like this;
Your values should appear to your DataGridView. Your changes will be direct to the DataGridView.
DataTable dt = new DataTable();
dt.Columns.Add("Days", typeof(int));
dt.Columns.Add("Amount", typeof(decimal));
dt.Rows.Add(1, 10.00m);
dt.Rows.Add(2, 10.00m);
dt.Rows.Add(3, 10.00m);
dt.Rows.Add(4, 10.00m);
dt.Rows.Add(5, 10.00m);
dt.Rows.Add(24, 10.00m);
dataGridView1.DataSource = dt;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.