-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
41 lines (36 loc) · 1.14 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Data;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
Random random = new Random();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
gridControl1.ShowPrintPreview();
}
private void Form1_Load(object sender, EventArgs e)
{
productsBindingSource.DataSource = GetProductsDataTable();
}
DataTable GetProductsDataTable()
{
DataTable table = new DataTable();
table.TableName = "Products";
table.Columns.Add(new DataColumn("ProductName", typeof(string)));
table.Columns.Add(new DataColumn("UnitPrice", typeof(double)));
table.Columns.Add(new DataColumn("UnitsOnOrder", typeof(int)));
for(int i = 0; i < 20; i++)
{
int index = i + 1;
table.Rows.Add("Product " + index, Math.Round(random.NextDouble() * 1000, 2), random.Next(0, 9) * 10);
}
return table;
}
}
}