/// <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; } } } }
效果图
原文:https://www.cnblogs.com/yuanshuo/p/13710545.html