1
I’m trying to send the data of a gridview
in a second Form
for a combobox
in the form
but I haven’t been successful. I wonder if there is a way to do this without sending as a parameter, since I will call the form
main at other times without needing this value.
Follow the attempt code:
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
Form1 f = new Form1();
f.cbComputador.SelectedIndex = Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value);
this.Close();
}
I need the value to appear immediately on combobox
"Computer" when user gives two clicks.
In the case of parameters you can leave it as Optional, already assigning a value to it type in the constructor for example public Form2(int? cbComputadorSelected = -1){ } When assigning to the combo you validate if there is value in the variable type cbComadorputSelected > -1 .. You would assign the index.. So you can call the main form at other times without having
– Edenilson Bila
Please exemplify with code snippet and add as answer to the question?
– DLopes
I’ll set an example to post
– Edenilson Bila
They’ve done it kkk
– Edenilson Bila
Thank you for your attention anyway...
– DLopes
@Managed to solve the problem? The answer meets the request or needs to improve on something?
– Jéf Bueno
It was very helpful. I’ve already marked it as a response. Thank you
– DLopes