private void button1_Click(object sender, EventArgs e) { Zavod item = new Zavod(textBox1.Text, Convert.ToInt32(textBox4.Text), textBox3.Text, Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox5.Text)); BindSource.Add(item); textBox1.Text = ""; textBox4.Text = ""; textBox3.Text = ""; textBox2.Text = ""; textBox5.Text = ""; }
private void button8_Click(object sender, EventArgs e) { dataGridView1.Rows.Clear(); OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { XmlDocument doc = new XmlDocument(); doc.Load(openFileDialog.FileName); XmlNodeList galleriesXmlList = doc.GetElementsByTagName("gallery"); List <Zavod> list = new List <Zavod>(); foreach (XmlElement item in galleriesXmlList) { list.Add(Zavod.FromXmlElement(item)); } foreach (Zavod g in list) { BindSource.Add(g); } } }
private void Form1_Load(object sender, EventArgs e) { ZavodList = new List <Zavod>(); BindSource = new BindingSource(); var item1 = new Zavod("Durkot", 5, "Mechanic", 25, 25000); var item2 = new Zavod("Kobal", 6, "Mechanic", 18, 30000); var item3 = new Zavod("Luts", 7, "Mechanic", 21, 25000); var item4 = new Zavod("Vayda", 8, "Mechanic", 5, 25000); var item5 = new Zavod("Antal", 9, "Mechanic", 13, 25000); ZavodList.Add(item1); ZavodList.Add(item2); ZavodList.Add(item3); ZavodList.Add(item4); ZavodList.Add(item5); BindSource.DataSource = ZavodList; dataGridView1.DataSource = BindSource; dataGridView1.Columns["Surname"].HeaderText = "Surname"; dataGridView1.Columns["Id"].HeaderText = "Id"; dataGridView1.Columns["Position"].HeaderText = "Position"; dataGridView1.Columns["Experience"].HeaderText = "Experience"; dataGridView1.Columns["Salary"].HeaderText = "Salary"; }