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         } 

 

 

 

posted @ 2012-12-25 15:57  杨斌_济南  阅读(1883)  评论(0编辑  收藏  举报