Answer the question
In order to leave comments, you need to log in
Why isn't the right Item selected from comboBox1 when I click on the button?
private void Form4_Load(object sender, EventArgs e)
{
comboBox1.Items.Add("Коломиец Андрей Михайлович");
comboBox1.Items.Add("Чкалов Павел Сергеевич");
comboBox1.Items.Add("Шумаков Олег Константинович");
comboBox1.Items.Add("Костров Олег Никитич");
comboBox1.Items.Add("Варашилов Никита Игоревич");
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < dataGridView1.RowCount; i++)
{
dataGridView1.Rows[1].Selected = false;
for (int j = 0; j < dataGridView1.ColumnCount; j++)
if (dataGridView1.Rows[i].Cells[j].Value != null)
if (dataGridView1.Rows[i].Cells[j].Value.ToString().Contains(comboBox1.Text))
{
dataGridView1.Rows[i].Selected = true;
break;
}
}
dataGridView1.DataSource = controller.UpdataSorudniki();
}
Answer the question
In order to leave comments, you need to log in
not an expert on winforms, but it seems to me that it's all about the line
dataGridView1.DataSource = controller.UpdataSorudniki();
In the DataGrid parameters there is a parameter responsible for the type of selection: "Single cell", "Entire row", etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question