jeudi 10 décembre 2020

how to display selected row in textbox MVP c#

I have MVP project iam trying to display the selected row to 3 textboxs and 1 checkbox : i know i can do it from the CellClick event like so :

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
    int index = e.RowIndex;// get the Row Index
    DataGridViewRow selectedRow = dataGridView1.Rows[index];
    textBox1.Text = selectedRow.Cells[0].Value.ToString();
    textBox2.Text = selectedRow.Cells[1].Value.ToString();
    textBox3.Text = selectedRow.Cells[2].Value.ToString();
    textBox4.Text = selectedRow.Cells[3].Value.ToString();
    checkBox1.Checked = Convert.ToBoolean(selectedRow.Cells[4].Value);
} 

But i want to call it from other class called Presenter but iam getting errors :

1.The name 'e' does not exist in the current context . 2. 'object' does not contain a definition for 'Rows' and no accessible extension method 'Rows' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) . 3.Cannot implicitly convert type 'string' to 'int'.

Thanks...

Aucun commentaire:

Enregistrer un commentaire