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);
                    }
                }
            }
     
  • 相关阅读:
    博客是一种心情
    双显示器和双鼠标
    C++ Primer Plus 第六版 代码笔记
    Bug,昂首走进2005
    让万能五笔2004免费版改首页的功能见鬼去吧。
    Gmail提供POP3和SMTP已经老长时间了
    快过年回家了,发点实用的东西给大家
    关于博客园Post的时候排版的一点小建议
    在.Net下进行MicroStation(GG)的开发(一)
    验证域的另一方法
  • 原文地址:https://www.cnblogs.com/zhangtao/p/2347573.html
Copyright © 2011-2022 走看看