• 设置dgv是否可编辑(封装DGV)


    1.循环遍历
            /// <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;
                        }
                    }
                }
            }

    2.指定列

                //可编辑
                dgvRecordList.Grid.Rows[0].Cells[nameof(DrugInout.DgInfo)].Activation = Activation.AllowEdit;
                //不可编辑
                dgvRecordList.Grid.Rows[0].Cells[nameof(DrugInout.DgInfo)].Activation = Activation.NoEdit;

     3.指定行

    //可以编辑(如果指定行可以编辑,但是实际运行不可编辑,必须先指定列可编辑)
    dgvMain.Grid.ActiveRow.Cells[nameof(MdvcDeprPrdVo.DdpBeginDt)].Activation = Activation.AllowEdit;

    效果图

  • 相关阅读:
    surfer插值方法及提取插值结果 转载
    Surfer的grd数据转换成gmt可用的grd数据方法
    Appium+Python3+ Android入门
    Flask入门的第一个项目
    测试报告模板
    火狐浏览器之伪造IP地址
    获取apk的签名信息
    初识kibana
    Fiddler模拟post四种请求数据
    Python-正则表达式
  • 原文地址:https://www.cnblogs.com/yuanshuo/p/13710545.html
Copyright © 2020-2023  润新知