public static void DataGridView_LockColumn(DataGridViewProperties dataGridViewProperties, String name) { int index = dataGridViewProperties.IndexOf(name); if (index > -1 && index < dataGridViewProperties.dataGridView.Columns.Count) { DataGridViewColumn readOnlyColumn = dataGridViewProperties.dataGridView.Columns[index]; readOnlyColumn.ReadOnly = true; readOnlyColumn.DefaultCellStyle.BackColor = Color.WhiteSmoke; } }
public static float dataGridView_ColumnSum(DataGridViewProperties properties, String name) { float sum = 0F; foreach (DataGridViewRow row in properties.dataGridView.Rows) { float number = 0; float.TryParse(row.Cells[properties.IndexOf(name)].Value.ToString(), out number); sum += number; } return sum; }