• Developer Express控件gridcontrol中gridView的某一个单元格是否可以自由输入


    场景:在Developer Express控件gridcontrol中的gridView中,当医生开的临时医嘱的医嘱类型为"中草药","计价总量"单元格不可以自由可输入,其余的医嘱类型,"计价总量"则可以自由输入。

    由于查询资料,只有设置列的属性,没有设置某一个单元格的属性。参考链接:http://www.docin.com/p-278065085.html

    解决办法:通过行焦点改变事件和列焦点改变事件进行控制单元格是否可用输入。

            private void gridView_Lsyz_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
            {
                if (this.CurrentOperationState == OperationState.emAddTempMedOrd || this.CurrentOperationState == OperationState.emEditTempMedOrd)
                {
                    if (gridView_Lsyz.FocusedRowHandle >= 0)
                    {
                        //case 16954
                        object objyzlx = gridView_Lsyz.GetRowCellValue(gridView_Lsyz.FocusedRowHandle, colYzlx);
                        if (objyzlx != null && objyzlx.ToString() != "")
                        {
                            if (objyzlx.ToString() == "自备药品")
                            {
                                if (ZBYIsFreeInput)
                                {
                                    this.GridViewReadOnly(gridView_Lsyz, "DOSEUNIT", false);
                                }
                            }
                            if (objyzlx.ToString() == "中草药")
                            {
                                //中草药计价总量不可输入Case#27998
                                this.GridViewReadOnly(gridView_Lsyz, "AMOUNT", true);
                            }
                            else
                            {
                                this.GridViewReadOnly(gridView_Lsyz, "DOSEUNIT", true);
                                //非中草药计价总量可输入Case#27998
                                this.GridViewReadOnly(gridView_Lsyz, "AMOUNT", false);
                            }
                        }
                    }
                }
            }
            private void gridView_Lsyz_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e)
            {
                if (gridView_Lsyz.FocusedRowHandle >= 0)
                {
                    DataRow currentRow = gridView_Lsyz.GetDataRow(gridView_Lsyz.FocusedRowHandle);
                    if (currentRow["MEDORDTYPE"].ToString() != "中草药")
                    {
                        gridView_Lsyz.Columns["DOSECOUNT"].OptionsColumn.AllowFocus = false;
                        this.GridViewReadOnly(gridView_Lsyz, "AMOUNT", false);//非中草药计价总量可输入Case#27998
                    }
                    else
                    {
                        gridView_Lsyz.Columns["DOSECOUNT"].OptionsColumn.AllowFocus = true;
                        this.GridViewReadOnly(gridView_Lsyz, "AMOUNT", true);//如果是中草药计价总量不可输入Case#27998
                    }
                }
            }
      public void GridViewReadOnly(DevExpress.XtraGrid.Views.Grid.GridView gridView, string columnsName, bool readOnly)
            {
                if (!readOnly)
                {
                    gridView.Columns[columnsName].OptionsColumn.ReadOnly = false;
                    gridView.Columns[columnsName].OptionsColumn.AllowFocus = true;
                    gridView.Columns[columnsName].OptionsColumn.AllowSize = true;
    
                }
                else
                {
                    gridView.Columns[columnsName].OptionsColumn.ReadOnly = true;
                    gridView.Columns[columnsName].OptionsColumn.AllowFocus = true;
                    gridView.Columns[columnsName].OptionsColumn.AllowSize = true;
                }
            }
  • 相关阅读:
    纯CSS星级评价
    Enterprise Library启用签名后发生 PublicKeyToken错误,HRESULT:0x80131040解决
    SQL Server
    该如何选择国外VPS
    网站的伪静态化
    kernel FIELD_SIZEOF宏 NULL地址不访问不出错
    Activity的四种加载模式
    Git magic 简短git使用命令集
    为什么包含多句代码的宏要用do while包括起来?
    使用lsof来查看FD和进程的关系
  • 原文地址:https://www.cnblogs.com/rwh871212/p/6755496.html
Copyright © 2020-2023  润新知