so I here is my code: I have 2 forms, - abutton in form1 takes you to form2 . -form2 has Datagridview in it - you enter the informations(name, age) in form 1 and then you load them in a datagridview in form2 -when I chose a row to delete fom datagrid view I want that row to be deleted too from the array.(how can I do it) thankyou in advance
class Class1
{
public struct client
{
public string nom;
public string prenom;
public int age;
}
public static client[] TC = new client[100];
public static int i = 0;
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
}
private void btn_ajouter_Click(object sender, EventArgs e)
{
Class1.TC[Class1.i].nom = textBox_nom.Text;
Class1.TC[Class1.i].prenom = textBox_prenom.Text;
Class1.TC[Class1.i].age = int.Parse(textBox_age.Text);
textBox_age.Clear();
textBox_nom.Clear();
textBox_prenom.Clear();
Class1.i = Class1.i + 1;
}
}
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void btn_afficher_Click(object sender, EventArgs e)
{
dataGridView1.Rows.Clear();
for (int j = 0; j <= Class1.i-1; j++)
{
dataGridView1.Rows.Add(Class1.TC[j].nom,Class1.TC[j].prenom,Class1.TC[j].age);
}
}
private void btn_supprimer_Click(object sender, EventArgs e)
{
dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
}
}