public override object Clone() { MyDataGridViewButtonCell cell = (MyDataGridViewButtonCell)base.Clone(); cell.ButtonVisible = this.ButtonVisible; return(cell); }
private void LoadCasovi(MojaKursInstancaProsireniModel result) { gridCasovi.DataSource = result.Casovi.OrderBy(c => c.DatumVrijemeOdrzavanja).ToList(); gridCasovi.Columns[nameof(CasModel.Id)].Visible = false; gridCasovi.Columns[nameof(CasModel.Opis)].Visible = false; gridCasovi.Columns[nameof(CasModel.Odrzan)].Visible = false; gridCasovi.Columns[nameof(CasModel.DatumVrijemeOdrzavanja)].HeaderText = "Vrijeme održavanja"; gridCasovi.Columns[nameof(CasModel.DatumVrijemeOdrzavanja)].DisplayIndex = 1; gridCasovi.Columns[nameof(CasModel.Lokacija)].DisplayIndex = 2; //below is header cell for each row with count number if (gridCasovi.Columns["Number"] == null) { DataGridViewTextBoxColumn numberCell = new DataGridViewTextBoxColumn() { Name = "Number", HeaderText = "#", DisplayIndex = 0, Width = 20 }; gridCasovi.Columns.Add(numberCell); } if (gridCasovi.Columns["Akcija"] == null) { MyDataGridViewButtonColumn buttonColumn = new MyDataGridViewButtonColumn() { Name = "Akcija", HeaderText = "Akcija", Text = "Označi kao održan", UseColumnTextForButtonValue = true, Width = 150, }; gridCasovi.CellClick += gridCasovi_OdrzanButton_CellClick; gridCasovi.Columns.Add(buttonColumn); } gridCasovi.Columns["Akcija"].DisplayIndex = 3; foreach (DataGridViewRow row in gridCasovi.Rows) { row.Cells[gridCasovi.Columns["Number"].Index].Value = row.Index + 1 /*gridCasovi.Rows.Count - row.Index*/; MyDataGridViewButtonCell buttonCell = (MyDataGridViewButtonCell)row.Cells[gridCasovi.Columns["Akcija"].Index]; bool odrzan = bool.Parse((row.Cells[gridCasovi.Columns[nameof(CasModel.Odrzan)].Index].Value).ToString()); if (odrzan) { gridCasovi.Rows[row.Index].Cells[gridCasovi.Columns["Number"].Index].Style.BackColor = Color.Green; buttonCell.Enabled = false; } else { gridCasovi.Rows[row.Index].Cells[gridCasovi.Columns["Number"].Index].Style.BackColor = Color.Red; buttonCell.Enabled = true; } } }
public MyDataGridViewButtonColumn() { CellTemplate = new MyDataGridViewButtonCell(); NewRowButtonVisible = false; }
public MyDataGridViewButtonColumn() { CellTemplate = new MyDataGridViewButtonCell(); }