zoukankan      html  css  js  c++  java
  • DeveXpress之XtraGrid一些知识

    DeveXpress

    1.XtraGrid

      1.1字段设定

      (1)Run Designer

      (2)选择对应的GridView

      (3)点击 Colums

      (4)点击Add添加列,需设置Name(字段名),FiledName(绑定名),Caption(显示名)



      1.2添加下级GridView

      (1)点击Level添加新的GridView

      (2)选择父GridView的MasterRowGetChildList事件

      (3)在事件中敲入(例子)

      var view = (GridView)sender;

      //从主Grid取出当前点击行的某个字段的值

      long Code = (long)view.GetFousedRowCellValue("ForderCode")

      //从数据库中取出相应的数据赋给嵌套在里面的Grid

      e.ChildList =
    BVTproductBelongAndProduct.Select(tp=>tp.ForderCode==Code).ToList();

      (4)如果绑定是视图或者其他,需指定其对应的两个MasterRowGetRelation事件和MasterRowGetRelation事件

      MasterRowGetRelation事件

      实例:

    //指定关系名 

     private void GridView_Franchise_MasterRowGetRelation(object
          sender.MaterRowGetRelationNameEventArgs e)

    {

    e.RelationName="TOrder"

    }

    //指定数量

    private void GridView_Franchise_MasterRowGetRelation(object       sender.MaterRowGetRelationCountEventArgs e)

    {

    e.RelationCount=1

    }

    1.3获取子GridView的行的数据

    (1)触发行点击MouseDown事件,获取Gridview dv= (GridView)sender

    (2)获取对应的实体信息

    int [] i = dv.GetSelectedRows();

    VTAgencyAndContract vtaac = (VTAgencyAndContract) dv.GetRow(i[0]);

    FContractId = vtacc.FContractId

    1.4常用语句

    (1)获取某一列的值

    WorkmanshipGridView
    .GetRowCellValue(this.WorkManshipGridView.FousedRowHandle,列名)

    或者(int)WorkManshipGridView.GetFouseRowCellValue(列名)

    (2)获取对象

    WorkManShipGridView.GetRow(WorkManShipGridView.FocusedRowHandle) as 对象类型

    或者WorkManShipGridView.GetFocusedRow() as 对象类型

    (3) 是否允许编辑 this.TproductGridView.OptionBehavior.Editable = false/true

    (4) 刷新Grid WorkmanshipGridControl.RefreshDataSource();

    (5)为某一列赋值
    TproductProcessGridView.SetRowCellValue(e.RowHandle,WMinCycle,e.Value)


    private void gridDeliveryDetail_KeyDown(object sender, KeyEventArgs e)
            {
                
    if (e.KeyCode == Keys.Delete)
                {
                    
    if (MessageBox.Show("删除行?""确认", MessageBoxButtons.YesNo) != DialogResult.Yes)
                        
    return;
                    
    int i = viewDeliveryDetail.FocusedRowHandle;
                    
    if (i >= 0)
                    {
                        viewDeliveryDetail.DeleteRow(i);
                    }
                }
            }
     
  • 相关阅读:
    javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    Maven无法下载com.oracle:ojdbc14:jar解决方法
    打赏
    badge徽章、挂件模版
    adb修改手机分辨率
    git忽略上传文件git忽略上传文件
    python爬虫用drony转发进行抓包转发
    pycharm远程服务器进行调试
    Ubuntu上latex+atom配置
    Ubuntu下设置开机后自动运行命令
  • 原文地址:https://www.cnblogs.com/zhangtao/p/2347573.html
Copyright © 2011-2022 走看看