• 一、Dev单元格


    二、获取表格数据

     int selectRow = gridView1.GetSelectedRows()[0];
     string id = this.gridView1.GetRowCellValue(selectRow, "id").ToString();
    

      

                string colValue = this.gridView1.GetRowCellValue(this.gridView1.FocusedRowHandle, this.gridView1.Columns["qty"]).ToString();
                var s = gridView1.GetDataRow(e.RowHandle)["列名"].ToString();  //当前单元格所在行的数据
            注意 e.value 获取当前编辑的值,上面对编辑单元格无效,只可以触发 GridView1_CellValueChanging 事件

      

    '设置单元格中的值
    GridView.SetRowCellValue(GridView.FocusedRowHandle, GridView.Columns("列名"),"要设置的值")
     
    '得到单元格中的值
    Me.GridView_Analysis.GetRowCellValue(GridView.FocusedRowHandle, "列名")
     
    '数据表中当前单元格的值
    DataSet.Tables(0).Rows(GridView.FocusedRowHandle).Item("列名")
    

    一、Dev单元格只允许输入数字 

            private void GridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
            {
                if (Convert.ToInt32(this.gridView1.GetDataRow(e.RowHandle)["qty"]) < e.Value.ToInt())
                {
                    this.gridView1.SetRowCellValue(e.RowHandle, "pick_qty", Convert.ToInt32(this.gridView1.GetDataRow(e.RowHandle)["qty"]));
                    this.gridView1.SetRowCellValue(e.RowHandle, "qty-pick_qty", 0);
                }
                else if (e.Value.ToString() == "")
                {
                    this.gridView1.SetRowCellValue(e.RowHandle, "pick_qty", 0);
                    this.gridView1.SetRowCellValue(e.RowHandle, "qty-pick_qty", Convert.ToInt32(this.gridView1.GetDataRow(e.RowHandle)["qty"]));
                }
                else
                {
                    this.gridView1.SetRowCellValue(e.RowHandle, "qty-pick_qty", Convert.ToInt32(this.gridView1.GetDataRow(e.RowHandle)["qty"]) - e.Value.ToInt());
                }
            }
    
            private void GridData_EditorKeyPress(object sender, KeyPressEventArgs e)
            {
                GridControl grid = sender as GridControl;
                gridView1_KeyPress(grid.FocusedView, e);
            }
            private void gridView1_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar == '' || e.KeyChar == '
    ')
                {
                    e.Handled = false;
                    return;
                }
                GridView view = sender as GridView;
                string s = "0123456789";
                if (view.FocusedColumn.FieldName == "pick_qty" && s.LastIndexOf(e.KeyChar) >= 0)
                {
                    e.Handled = false;
    
                }
                else
                    e.Handled = true;
            }
    

      

  • 相关阅读:
    附件下载遇到 ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION 错误
    Javascript模块编程&jQuery插件开发学习笔记
    网站推荐
    分布式服务下Quartz任务变为EREOR分析及解决
    Quartz任务监听器
    定时任务框架Quartz基本使用
    2020年CKA考试分享
    vue-element-loading 动态插件
    pycharm之常用插件
    PHP开源项目之YOURLS
  • 原文地址:https://www.cnblogs.com/fger/p/10337769.html
Copyright © 2020-2023  润新知