private void button4_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridView1.SelectedRows) { string value1 = row.Cells[0].Value.ToString(); string value2 = row.Cells[1].Value.ToString(); string value3 = row.Cells[2].Value.ToString(); string value4 = row.Cells[3].Value.ToString(); string value5 = row.Cells[4].Value.ToString(); string value6 = row.Cells[5].Value.ToString(); string value7 = ""; if (GetAmount.InputBox("Кількість етикеток " + value2, "Кількість:", ref value7) != DialogResult.OK) { return; } printMark(value2, value3, value4, value5, value6, value7, ""); } }
private void button5_Click(object sender, EventArgs e) { string searchValue = ""; if (GetAmount.InputBox("Пошук", "Введіть ключове слово або фразу:", ref searchValue) != DialogResult.OK) { return; } //int rowIndex = -1; //DataGridViewRow row = dataGridView1.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["Names"].Value.ToString().Equals(searchValue)).First(); dataGridView1.ClearSelection(); foreach (DataGridViewRow row in dataGridView1.Rows) { if ((row.Cells[1].Value != null) && (row.Cells[1].Value.ToString().Equals(searchValue))) { dataGridView1.Rows[row.Index].Selected = true; } if ((row.Cells[1].Value != null) && (row.Cells[2].Value.ToString().Equals(searchValue))) { dataGridView1.Rows[row.Index].Selected = true; } if ((row.Cells[1].Value != null) && (row.Cells[3].Value.ToString().Equals(searchValue))) { dataGridView1.Rows[row.Index].Selected = true; } if ((row.Cells[1].Value != null) && (row.Cells[4].Value.ToString().Equals(searchValue))) { dataGridView1.Rows[row.Index].Selected = true; } if ((row.Cells[1].Value != null) && (row.Cells[5].Value.ToString().Equals(searchValue))) { dataGridView1.Rows[row.Index].Selected = true; } } }