private void btnDodaj_Click(object sender, EventArgs e) { if (!(dataGridView1["Rbr", dataGridView1.Rows.Count - 1].Value.ToString() == BrojCasa)) { oblik = ""; boja = ""; masaMin = "0"; masaMax = "127"; Dodaj form = new Dodaj(); form.ShowDialog(); form.Dispose(); if (novi_podatak) { int last = int.Parse(dataGridView1["Rbr", dataGridView1.Rows.Count - 1].Value.ToString()); dataGridView1["Rbr", last - 1].Value = last + 1; dataGridView1.Rows.Insert(last - 1, last.ToString(), oblik, boja, masaMin, masaMax, "Uredi", "Ukloni"); novi_podatak = false; } } else { MessageBox.Show("Nije moguće dodati više boxova"); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { int last = int.Parse(dataGridView1["Rbr", dataGridView1.Rows.Count - 1].Value.ToString()); if (e.RowIndex == last - 1) //zadnji { MessageBox.Show("Nije moguće uređivati zadnji red"); } //zadnji else if (e.ColumnIndex == 5) //uredi { oblik = dataGridView1[1, e.RowIndex].Value.ToString(); boja = dataGridView1[2, e.RowIndex].Value.ToString(); masaMin = dataGridView1[3, e.RowIndex].Value.ToString(); masaMax = dataGridView1[4, e.RowIndex].Value.ToString(); Dodaj form = new Dodaj(); form.ShowDialog(); form.Dispose(); if (novi_podatak) { dataGridView1.Rows.RemoveAt(e.RowIndex); dataGridView1.Rows.Insert(e.RowIndex, e.RowIndex + 1, oblik, boja, masaMin, masaMax, "Uredi", "Ukloni"); novi_podatak = false; } } //uredi else if (e.ColumnIndex == 6) //ukloni { dataGridView1.Rows.RemoveAt(e.RowIndex); correctRedniBroj(); } //ukloni } }