zoukankan      html  css  js  c++  java
  • C# DEV 树、Grid、下拉框等设定数据源对比

    ① 树(DevExpress.XtraTreeList.TreeList控件)

     1         /// <summary>
     2         /// 刷新本页面
     3         /// </summary>
     4         private void FreshDistrictInfo()
     5         {
     6             DistrictModel districtModel = new DistrictModel();
     7             string strDistrictModel = Newtonsoft.Json.JsonConvert.SerializeObject(districtModel);
     8             string strResult = WebLockConfig.Instance.webDistrictInfo.GetDistrictInfo(strDistrictModel);
     9             DataSet ds = Newtonsoft.Json.JsonConvert.DeserializeObject<DataSet>(strResult);
    10             treeDistrictInfo.DataSource = ds.Tables[0];
    11             treeDistrictInfo.Nodes[0].Expanded = true;
    12             districtModel = null;
    13         }  

    ②Grid(Ctrl.MyGridControl自定义)

     1         /// <summary>
     2         /// 刷新窗体
     3         /// </summary>
     4         private void FreshWindow()
     5         {
     6             ProvinceModel provinceModel = new ProvinceModel();
     7             provinceModel.PRO_ID = txtProID.Text.Trim();
     8             provinceModel.PRO_NAME = txtProName.Text.Trim();
     9 
    10             string strProvinceModel = Newtonsoft.Json.JsonConvert.SerializeObject(provinceModel);
    11             string strResult = WebLockConfig.Instance.webProvince.GetProvinceDS(strProvinceModel);
    12             DataSet ds = Newtonsoft.Json.JsonConvert.DeserializeObject<DataSet>(strResult);
    13             GCProvince.DataSource = ds.Tables[0];
    14             provinceModel = null;
    15         }


    ③ DevExpress.XtraEditors.LookUpEdit控件

     1         /// <summary>
     2         /// 绑定所属省份的数据
     3         /// </summary>
     4         private void BindCmbProvince()
     5         {
     6             ProvinceModel bindProvinceModel = new ProvinceModel();
     7             string strBindProvince = Newtonsoft.Json.JsonConvert.SerializeObject(bindProvinceModel);
     8             string strResult = WebLockConfig.Instance.webProvince.GetProvinceDS(strBindProvince);
     9             DataSet ds = Newtonsoft.Json.JsonConvert.DeserializeObject<DataSet>(strResult);
    10 
    11             DataRow dr = ds.Tables[0].NewRow();
    12             dr["PRO_ID"] = "";
    13             dr["PRO_NAME"] = "请选择";
    14             ds.Tables[0].Rows.InsertAt(dr,0);
    15             cmbProvince.SelectedText = "请选择";
    16             cmbProvince.Properties.DataSource = ds.Tables[0];
    17             cmbProvince.Properties.DropDownRows = ds.Tables[0].Rows.Count;
    18 
    19             bindProvinceModel = null;
    20             ds = null;
    21             dr = null;
    22         } 
  • 相关阅读:
    1:4 UI标签和通用标签
    1:3访问 servlet API 的两种方式(request,session等内置对象)
    1 :2 Strust2—Demo
    1:1 Struts2概述
    mysql索引原理与慢查询优化1
    mysql流程控制
    mysql函数
    mysql存储过程
    mysql事务
    mysql触发器
  • 原文地址:https://www.cnblogs.com/YangBinChina/p/2832565.html
Copyright © 2011-2022 走看看