GridControlClass公用方法
来源:互联网 发布:nero9刻录软件免费下载 编辑:程序博客网 时间:2024/05/22 02:42
using System;using System.Collections.Generic;using System.Linq;using System.Text;using ForeStar.CoreUI.Control;using ForeStar.CoreUI.Win.Control;using DevExpress.XtraGrid.Views.Grid;using System.Drawing;using ForeStar.Data.General;using ForeStar.CoreUI.Message;using ForeStar.GIS.SpatialDatabase;using MapZone.SpatialDatabase;namespace Forestar.GZ.YZL.Utils{ /// <summary> /// 定义GridContrl控件通用方法类 /// </summary> public class GridCommonMethod { public GridCommonMethod() { } /// <summary> /// 设置GridControl焦点行的背景颜色 /// </summary> /// <param name="form"></param> /// <param name="strGridControlName"></param> public void SetFocusRowBackColor(IDataForm form, string strGridControlName) { if (form == null || string.IsNullOrEmpty(strGridControlName)) return; GridControlClass gc = form.GetControl(strGridControlName) as GridControlClass; if (gc == null) return; GridView gv = gc.MainView as GridView; if (gv == null) return; gv.Appearance.FocusedRow.BackColor = Color.GreenYellow; } public static void SetFocusRow(IDataForm form, string strGridControlName) { if (form == null || string.IsNullOrEmpty(strGridControlName)) return; GridControlClass gc = form.GetControl(strGridControlName) as GridControlClass; if (gc == null || gc.DataSource == null) return; //List<IRow> lstIRow = null; //lstIRow = gc.DataSource as List<IRow>; //if (lstIRow == null) //{ // List<RowBase> lstRows = gc.DataSource as List<RowBase>; // if (lstRows != null && lstRows.Count != 0) // lstIRow = lstRows.ToList<IRow>(); //} //if (lstIRow == null) return; GridView gv = gc.MainView as GridView; if (gv == null) return; if (gv.DataRowCount == 0) return; gv.FocusedRowHandle = -1; gv.FocusedRowHandle = 0; } public int GetGridRowCount(IDataForm form, string strGridControlName) { int iCount = 0; if (form == null || string.IsNullOrEmpty(strGridControlName)) return iCount; GridControlClass gc = form.GetControl(strGridControlName) as GridControlClass; if (gc == null) return iCount; GridView gv = gc.MainView as GridView; if (gv == null) return iCount; iCount = gv.DataRowCount; return iCount; } /// <summary> /// 验证是否有数据源 /// </summary> /// <param name="gc"></param> /// <returns></returns> public static bool DataCheck(GridControlClass gc) { if (gc == null) return false; List<RowBase> lstRows = gc.DataSource as List<RowBase>; if (lstRows == null || lstRows.Count == 0) { MessageManager.Show("数据源不能为空!", "系统提示"); return false; } int SelectRows = 0; foreach (RowBase item in lstRows) { string strCheckBox = item.GetValue<string>("SHOWCHECKBOX"); if (string.IsNullOrEmpty(strCheckBox) || strCheckBox.ToUpper() != "TRUE") continue; SelectRows++; } if (SelectRows > 0) return true; else { MessageManager.Show("请选择一条记录!", "系统提示"); return false; } } /// <summary> /// 设计成果删除的公共方法 /// </summary> /// <param name="lstRow"></param> /// <param name="strTableName"></param> /// <param name="strUniFieldName"></param> public static bool DelFeatures(List<IRow> lstRow, string strTableName, string strUniFieldName) { if (lstRow == null || lstRow.Count == 0) { MessageManager.Show("请选择一条记录!", "系统提示"); return false; } if (string.IsNullOrEmpty(strTableName) || string.IsNullOrEmpty(strUniFieldName)) { LogManage.WriteLog("删除设计成果时,参数不能为空!"); return false; } ITable table_RG = ForeStar.Data.Metadata.MetadataWorkspaceClass.GetMetadataWorkspace.OpenTable(strTableName).Table; if (table_RG == null) { LogManage.WriteLog("设计成果删除时不能打开表【" + strTableName + "】"); return false; } try { foreach (IRow item in lstRow) { Int32 I_Pk_UID = item.GetValue<Int32>(strUniFieldName); IFeatureClass pFeaCls = table_RG as IFeatureClass; IMZDatasetVector dv = pFeaCls.InnerObject as IMZDatasetVector; if (dv != null) dv.DeleteFeature(I_Pk_UID); } return true; } catch (Exception ex) { LogManage.WriteLog(ex.ToString()); return false; } } }}
<pre name="code" class="csharp"> //设置GridControl行的背景颜色
GridControlClass pGrid = null;
private void SetRowBackColor(IDataForm form, string strGridControlName) { if (form == null || string.IsNullOrEmpty(strGridControlName)) return; pGrid = form.GetControl(strGridControlName) as GridControlClass; DevExpress.XtraGrid.Views.Grid.GridView focusView = pGrid.FocusedView as DevExpress.XtraGrid.Views.Grid.GridView; if (focusView == null) return; focusView.CustomDrawCell += new DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventHandler(focusView_CustomDrawCell); } void focusView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (pGrid == null) { return; } List<RowBase> rows = pGrid.DataSource as List<RowBase>; if (rows == null || rows.Count <= 0) return; if (e.RowHandle >= rows.Count) return; RowBase row = rows[e.RowHandle]; if (row.GetValue<string>("SFBG").ToString() == "3") { e.Appearance.BackColor = System.Drawing.Color.Cyan; } }
0 0
- GridControlClass公用方法
- C#报表公用方法
- webdriver 截图公用方法
- 四舍五入的公用方法
- 公用toString方法
- webdriver 截图公用方法
- 公用方法Store
- Object公用方法
- Object类公用方法
- 表单验证公用方法
- hibernate5 公用方法
- 定义系统公用变量方法
- CodeSmith 公用代码共享方法
- 常用js代码公用方法
- Js jquery 一些公用方法
- 我的框架:公用方法
- selenium+python剥离公用方法
- 导出excel公用js方法
- C# winform 引用Grid++Report
- javascript——窗口大小和视口大小
- python(第三天):参数匹配类型
- vim mark
- PLSQL连接不上,配置tnsnames.ora后连接失败的可能原因
- GridControlClass公用方法
- 哪种将pdf转换成为word的软件好用
- Java Socket实战之二:多线程通信
- Substring
- <td>小用法合集</td>
- 百盛车辆挂靠管理系统 下载
- 针对上个程序的改进 —— 贪吃蛇
- ATS线上报告个别日志过大无法写入问题的解决方法
- 输出 1 到最大的 N 位数