設定dgv是否可編輯(封裝DGV)
阿新 • • 發佈:2020-09-22
/// <summary> /// 設定藥品資訊是否可編輯 /// </summary> private void SetDataEdit(ref MzGridControl dgv) { List<DrugInout> datas = dgv.DataSource as List<DrugInout> ?? new List<DrugInout>(); dgv.Grid.DisplayLayout.Bands[0].Columns[nameof(DrugInout.DgInfo)].CellActivation = Activation.AllowEdit;if (datas != null && dgv.Grid.Rows.Count > 0) { foreach (var s in dgv.Grid.Rows) { if ((bool)s.Cells[nameof(DrugInout.IsNameNoEdit)].Value == true) { s.Cells[nameof(DrugInout.DgInfo)].Activation= Activation.NoEdit; } else { //s.Cells[nameof(DrugInout.DgInfo)].Activation = Activation.AllowEdit; //s.Cells[nameof(DrugInout.DgInfo)].Activation s.Cells[nameof(DrugInout.DgInfo)].Activation = Activation.AllowEdit; } } } }