Ejemplo n.º 1
0
        private void grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (grid.Rows[e.RowIndex].Cells["colCol1"].Value == null)
            {
                return;
            }

            if ((grid.Rows[e.RowIndex].Cells["colCol1"].Value.ToString().EndsWith("1")) ||
                (grid.Rows[e.RowIndex].Cells["colCol1"].Value.ToString().EndsWith("2")) ||
                (grid.Rows[e.RowIndex].Cells["colCol1"].Value.ToString().EndsWith("5")) ||
                (grid.Rows[e.RowIndex].Cells["colCol1"].Value.ToString().EndsWith("6")) ||
                (grid.Rows[e.RowIndex].Cells["colCol1"].Value.ToString().EndsWith("9")))
            {
                buttonCell                 = (DataGridViewDisableButtonCell)grid.Rows[e.RowIndex].Cells["Buttons"];
                buttonCell.Hide            = true;
                buttonCell.Style.BackColor = Color.Red;

                checkboxCell      = (DataGridViewDisableCheckBoxCell)grid.Rows[e.RowIndex].Cells["CheckBoxes"];
                checkboxCell.Hide = true;
            }
            else
            {
                buttonCell      = (DataGridViewDisableButtonCell)grid.Rows[e.RowIndex].Cells["Buttons"];
                buttonCell.Hide = false;
            }
        }
Ejemplo n.º 2
0
        // Override the Clone method so that the Hide property is copied.
        public override object Clone()
        {
            DataGridViewDisableButtonCell cell = (DataGridViewDisableButtonCell)base.Clone();

            cell.Hide = this.Hide;
            return(cell);
        }