zoukankan      html  css  js  c++  java
  • 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;
                }
            }
  • 相关阅读:
    checkbox 实现单选效果(html)
    HDU-6850 Game
    牛客练习赛29----F 算式子
    牛客多校第二场 B Boundary
    D. Omkar and Circle
    【洛谷】P3306 [SDOI2013]---- 随机数生成器
    二次剩余
    【洛谷】--P2704 [NOI2001]炮兵阵地
    【洛谷】4310 绝世好题
    快速排序
  • 原文地址:https://www.cnblogs.com/rwh871212/p/6755496.html
Copyright © 2011-2022 走看看