Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- namespace StudentiDataGrid
- {
- public partial class Form1 : Form
- {
- public string[,] studenti = new string[4, 4];
- public int j, k = 0;
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (j < 4)
- {
- studenti[j, 0] = textBox3.Text;
- studenti[j, 1] = textBox4.Text;
- studenti[j, 2] = textBox5.Text;
- j++;
- DataGridViewRow riga = new DataGridViewRow();
- riga.CreateCells(dataGridView1);
- for (int i = 0; i < 3; i++)
- riga.Cells[i].Value = studenti[j - 1, i];
- dataGridView1.Rows.Add(riga);
- }
- else
- MessageBox.Show("Numero massimo di inserimenti raggiunto.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (k < 4)
- {
- int voto_min = Convert.ToInt32(textBox6.Text);
- int assenze_max = Convert.ToInt32(textBox7.Text);
- for (int i = k; i < k + 1; i++)
- {
- if (Convert.ToInt32(studenti[i, 1]) >= voto_min && Convert.ToInt32(studenti[i, 2]) <= assenze_max)
- studenti[i, 3] = "Promosso";
- else
- studenti[i, 3] = "Bocciato";
- dataGridView1.Rows[i].Cells[3].Value = studenti[i, 3];
- }
- k++;
- }
- else
- MessageBox.Show("Numero massimo di inserimenti raggiunto.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement