| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using Infragistics.Win.UltraWinGrid;
- namespace Common
- {
- /// <summary>
- /// Grid数据处理类
- /// </summary>
- public class GridHelper
- {
- /// <summary>
- /// 删除记录激活指定行
- /// </summary>
- /// <param name="grid">ultraGrid</param>
- /// <param name="delRowIndex">删除行的索引</param>
- public static void GridAfterDelRow_ReSelectRow(ref Infragistics.Win.UltraWinGrid.UltraGrid grid, int delRowIndex)
- {
- if (grid.Rows.Count == 0) return;
- if ((delRowIndex + 1) > grid.Rows.Count)
- {
- grid.Rows[delRowIndex - 1].Activate();
- grid.Rows[delRowIndex - 1].Selected = true;
- }
- else
- {
- grid.Rows[delRowIndex].Activate();
- grid.Rows[delRowIndex].Selected = true;
- }
- }
- /// <summary>
- /// 清除UltraGrid的DataSource的数据
- /// </summary>
- /// <param name="ulGrid"></param>
- public static void ClearGridDataSourceData(Infragistics.Win.UltraWinGrid.UltraGrid ulGrid)
- {
- if (ulGrid.DataSource is DataSet)
- {
- for (int i = ((DataSet)ulGrid.DataSource).Tables.Count - 1; i >= 0; i--)
- {
- ((DataSet)ulGrid.DataSource).Tables[i].Rows.Clear();
- }
- }
- }
- /// <summary>
- /// 将ultragrid的数据导出到Excel中
- /// </summary>
- /// <param name="ulGrid">要导出数据的ulGrid名称</param>
- /// <param name="sFileName">Excel文件名</param>
- //public static void ulGridToExcel(Infragistics.Win.UltraWinGrid.UltraGrid ulGrid, string sFileName)
- //{
- // try
- // {
- // Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter ulGridExt = new Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter();
- // //ulGridExt.CellExporting += new Infragistics.Win.UltraWinGrid.ExcelExport.CellExportingEventHandler(ultraGridExcelExporter1_CellExporting);
- // System.Windows.Forms.SaveFileDialog saveFileDialog1 = new SaveFileDialog();
- // if (ulGrid.Rows.Count == 0)
- // {
- // MessageBox.Show("没有数据,无法导出!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- // }
- // saveFileDialog1.FileName = sFileName + DateTime.Now.ToString("yyyyMMdd");
- // saveFileDialog1.Filter = "Excel文件(*.xls)|*.xls";
- // if (saveFileDialog1.ShowDialog() == DialogResult.OK)
- // {
- // string sFullName = saveFileDialog1.FileName;
- // ulGridExt.Export(ulGrid, sFullName);
- // ProcessStartInfo p = new ProcessStartInfo(sFullName);
- // p.WorkingDirectory = Path.GetDirectoryName(sFullName);
- // Process.Start(p);
- // }
- // }
- // catch (Exception ex)
- // {
- // MessageBox.Show("导出失败,原因:" + ex.Message, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
- // }
- //}
- /// <summary>
- /// 将ultragrid的数据导出到Excel中
- /// </summary>
- /// <param name="ulGridList">ulGrid组</param>
- /// <param name="sheetNameList">顺序对应的Sheet名称</param>
- /// <param name="sFileName">Excel文件名</param>
- //public static void ulGridToExcel(ArrayList ulGridList, ArrayList sheetNameList, string sFileName)
- //{
- // try
- // {
- // Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter ulGridExt = new Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter();
- // //ulGridExt.CellExporting += new Infragistics.Win.UltraWinGrid.ExcelExport.CellExportingEventHandler(ultraGridExcelExporter1_CellExporting);
- // System.Windows.Forms.SaveFileDialog saveFileDialog1 = new SaveFileDialog();
- // saveFileDialog1.FileName = sFileName + DateTime.Now.ToString("yyMMdd") + ".xls";
- // if (saveFileDialog1.ShowDialog() == DialogResult.OK)
- // {
- // string sFullName = saveFileDialog1.FileName;
- // Infragistics.Excel.Workbook workbook1 = new Infragistics.Excel.Workbook();
- // for (int i = 0; i < ulGridList.Count; i++)
- // {
- // Infragistics.Win.UltraWinGrid.UltraGrid itemGrid = ulGridList[i] as Infragistics.Win.UltraWinGrid.UltraGrid;
- // string sheetname = (sheetNameList.Count > i && sheetNameList[i].ToString() != "")
- // ? sheetNameList[i].ToString() : ("sheet" + i.ToString());
- // workbook1.Worksheets.Add(sheetname);
- // //没有数据时会出错,所以没有数据的面不不调用
- // if (itemGrid.Rows.Count > 0)
- // ulGridExt.Export(itemGrid, workbook1.Worksheets[i]);
- // }
- // workbook1.Save(sFullName);
- // }
- // }
- // catch (Exception ex)
- // {
- // MessageBox.Show("导出失败,原因:" + ex.Message);
- // }
- //}
- /// <summary>
- /// 清除Grid的列过滤
- /// </summary>
- /// <param name="ulGrid">Grid名称</param>
- public static void ClearUlGridFilter(Infragistics.Win.UltraWinGrid.UltraGrid ulGrid)
- {
- ulGrid.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
- }
- /// <summary>
- /// 增加Grid的列过滤
- /// </summary>
- /// <param name="ulGrid"></param>
- public static void AddUlGridFilter(Infragistics.Win.UltraWinGrid.UltraGrid ulGrid)
- {
- ulGrid.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True;
- }
- /// <summary>
- /// 刷新Grid数据并根据数据调整Grid列宽
- /// </summary>
- /// <param name="ultraGrid">需要处理的Grid</param>
- public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid)
- {
- try
- {
- ultraGrid.DataBind();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
- {
- foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
- {
- column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- }
- }
- ultraGrid.Refresh();
- }
- catch { }
- }
- /// <summary>
- /// 获取grid 所有勾选的行
- /// </summary>
- /// <param name="grid"></param>
- /// <param name="columnName">复选框所在列名</param>
- /// <returns></returns>
- public static List<UltraGridRow> UltraGridGetChooseRows(UltraGrid grid, string columnName, bool IgnoreFiltered = false)
- {
- grid.UpdateData();
- List<UltraGridRow> list = new List<UltraGridRow>();
- RowsCollection rows = grid.Rows;
- foreach (var item in rows)
- {
- try
- {
- if (item.Cells!=null) {
- if (Convert.ToBoolean(item.Cells[columnName].Value) == true
- && (!IgnoreFiltered || !item.IsFilteredOut))
- {
- list.Add(item);
- }
- }
- }
- catch { }
- }
- return list;
- }
- /// <summary>
- /// 刷新Grid数据并根据数据调整Grid列宽 方法名错,弃用
- /// </summary>
- /// <param name="ultraGrid">需要处理的Grid</param>
- /// <param name="cols">不需要调整列宽的列</param>
- public static void RefreshAndAutoSizeExceptRows(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid, Infragistics.Win.UltraWinGrid.UltraGridColumn[] cols)
- {
- RefreshAndAutoSizeExceptColumns(ultraGrid, cols);
- }
- /// <summary>
- /// 刷新Grid数据并根据数据调整Grid列宽
- /// </summary>
- /// <param name="ultraGrid">需要处理的Grid</param>
- /// <param name="cols">不需要调整列宽的列</param>
- public static void RefreshAndAutoSizeExceptColumns(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid, Infragistics.Win.UltraWinGrid.UltraGridColumn[] cols)
- {
- try
- {
- ultraGrid.DataBind();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
- {
- foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
- {
- if (cols != null && cols.Contains(column))
- {
- continue;
- }
- column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- }
- }
- ultraGrid.Refresh();
- }
- catch { }
- }
- /// <summary>
- /// 刷新Grid数据并根据数据调整Grid列宽
- /// </summary>
- /// <param name="ultraGrid">需要处理的Grid</param>
- /// <param name="cols">不需要调整列宽的列</param>
- public static void RefreshAndAutoSizeExceptColumns(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid, params string[] columns)
- {
- try
- {
- ultraGrid.DataBind();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
- {
- foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
- {
- if (columns != null && columns.Contains(column.Key))
- {
- continue;
- }
- column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
- }
- }
- ultraGrid.Refresh();
- }
- catch { }
- }
- /// <summary>
- /// 复制DataTable
- /// </summary>
- /// <param name="src">源DataTable</param>
- /// <param name="dest">目标DataTable</param>
- /// <param name="ClearExists">是否清除目标DataTable现有数据</param>
- public static void CopyDataToDatatable(ref DataTable src, ref DataTable dest, bool ClearExists)
- {
- if (src == null || dest == null)
- {
- return;
- }
- if (ClearExists)
- {
- dest.Rows.Clear();
- }
- DataRow CurRow, NewRow;
- for (int i = 0; i < src.Rows.Count; i++)
- {
- CurRow = src.Rows[i];
- NewRow = dest.NewRow();
- for (int j = 0; j < src.Columns.Count; j++)
- {
- try
- {
- if (dest.Columns.Contains(src.Columns[j].ColumnName))
- {
- NewRow[src.Columns[j].ColumnName] = CurRow[j];
- }
- }
- catch { }
- }
- dest.Rows.Add(NewRow);
- }
- }
- /// <summary>
- /// 复制DataTable
- /// </summary>
- /// <param name="src">源DataTable</param>
- /// <param name="dest">目标DataTable</param>
- /// <param name="ClearExists">是否清除目标DataTable现有数据</param>
- public static void CopyDataToDatatable(DataTable src, DataTable dest, bool ClearExists)
- {
- if (src == null || dest == null)
- {
- return;
- }
- if (ClearExists)
- {
- dest.Rows.Clear();
- }
- DataRow CurRow, NewRow;
- for (int i = 0; i < src.Rows.Count; i++)
- {
- CurRow = src.Rows[i];
- NewRow = dest.NewRow();
- for (int j = 0; j < src.Columns.Count; j++)
- {
- try
- {
- if (dest.Columns.Contains(src.Columns[j].ColumnName))
- {
- NewRow[src.Columns[j].ColumnName] = CurRow[j];
- }
- }
- catch { }
- }
- dest.Rows.Add(NewRow);
- }
- }
- /// <summary>
- /// 复制DataTable并添加ArrayList数据列
- /// </summary>
- /// <param name="src">源DataTable</param>
- /// <param name="dest">目标DataTable</param>
- /// <param name="ClearExists">是否清除目标DataTable现有数据</param>
- /// <param name="alistColumns">列名集合</param>
- /// <param name="alistValue">数据集合</param>
- public static void CopyDataToDatatable(ref DataTable src, ref DataTable dest, bool ClearExists, ArrayList alistColumns, ArrayList alistValue)
- {
- if (src == null || dest == null)
- {
- return;
- }
- if (ClearExists)
- {
- dest.Rows.Clear();
- }
- DataRow CurRow, NewRow;
- for (int i = 0; i < src.Rows.Count; i++)
- {
- CurRow = src.Rows[i];
- NewRow = dest.NewRow();
- for (int j = 0; j < src.Columns.Count; j++)
- {
- try
- {
- if (dest.Columns.Contains(src.Columns[j].ColumnName))
- {
- NewRow[src.Columns[j].ColumnName] = CurRow[j];
- }
- }
- catch { }
- }
- if (alistColumns != null && alistValue != null)
- {
- for (int idx = 0; idx < alistColumns.Count; idx++)
- {
- try
- {
- if (dest.Columns.Contains(alistColumns[idx].ToString()))
- {
- NewRow[alistColumns[idx].ToString()] = alistValue[idx];
- }
- }
- catch { }
- }
- }
- dest.Rows.Add(NewRow);
- }
- }
- /// <summary>
- /// Grid是否包含列
- /// </summary>
- /// <param name="grid">UltraGrid</param>
- /// <param name="strColumn">列名</param>
- /// <returns>有返回true 无返回false</returns>
- public static bool GridContainsColumn(ref Infragistics.Win.UltraWinGrid.UltraGrid grid, string strColumn)
- {
- for (int i = 0; i < grid.DisplayLayout.Bands[0].Columns.Count; i++)
- {
- if (grid.DisplayLayout.Bands[0].Columns[i].Key.Equals(strColumn))
- return true;
- }
- return false;
- }
- /// <summary>
- /// Grid是否包含列
- /// </summary>
- /// <param name="grid">UltraGrid</param>
- /// <param name="BandIndex">UltraGrid绑定数据集数组下标</param>
- /// <param name="strColumn">列名</param>
- /// <returns>有返回true 无返回false</returns>
- public static bool GridContainsColumn(ref Infragistics.Win.UltraWinGrid.UltraGrid grid, int BandIndex, string strColumn)
- {
- if (BandIndex <= grid.DisplayLayout.Bands.Count - 1)
- {
- for (int i = 0; i < grid.DisplayLayout.Bands[BandIndex].Columns.Count; i++)
- {
- if (grid.DisplayLayout.Bands[BandIndex].Columns[i].Key.Equals(strColumn))
- return true;
- }
- }
- return false;
- }
- /// <summary>
- /// 获取Table中最大编号,自增1返回。
- /// </summary>
- /// <param name="dt"></param>
- /// <returns></returns>
- //public static string AutoCode(DataTable dt)
- //{
- // int maxCode = 0;
- // //substring去除S001中的S,得到001。
- // string maxCodeString = dt.Rows[0][0].ToString().Substring(1);
- // //是否为数字
- // if (StringUtil.IsNumber(maxCodeString))
- // {
- // maxCode = Convert.ToInt32(maxCodeString);
- // }
- // else
- // {
- // MessageBox.Show("传入编号格式有误,请查看代码!", "提示");
- // }
- // //比较得出最大id。
- // for (int i = 1; i < dt.Rows.Count; i++)
- // {
- // string maxCodeString_Two = dt.Rows[i][0].ToString().Substring(1);
- // int maxCode_Two = 0;
- // if (StringUtil.IsNumber(maxCodeString_Two))
- // {
- // maxCode_Two = Convert.ToInt32(maxCodeString_Two);
- // if (maxCode_Two > maxCode)
- // {
- // maxCode = maxCode_Two;
- // }
- // }
- // }
- // //新增行
- // maxCode += 1;
- // string codeTop = "";
- // if (maxCode < 10)
- // {
- // codeTop = "00";
- // }
- // else if (maxCode < 100)
- // {
- // codeTop = "0";
- // }
- // //获取头文字D。
- // string d = dt.Rows[0][0].ToString().Substring(0, 1);
- // //头文字+0+最大数字
- // string newCode = d + codeTop + maxCode;
- // return newCode;
- //}
- /// <summary>
- /// 根据关键字快速查找父表的UltaGridRow数组。
- /// </summary>
- /// <param name="grid">UltraGrid</param>
- /// <param name="columnNames">列名</param>
- /// <param name="keys">key值</param>
- /// <returns>UltraGridRow数组</returns>
- /// 2014年11月29日 15:25:26 cx
- public static UltraGridRow[] GetRowsWithKey(UltraGrid grid, string[] columnNames, string[] keys)
- {
- UltraGridRow[] rows = null;
- IQueryable<UltraGridRow> queryableRow = grid.Rows.AsQueryable();
- if (columnNames.Length != keys.Length)
- {
- throw new Exception("列名数组与key值数组长度不一致!");
- }
- for (int i = 0; i < columnNames.Length; i++)
- {
- queryableRow = GetQueryResult(queryableRow, columnNames[i], keys[i]);
- }
- rows = queryableRow.ToArray();
- return rows;
- }
- private static IQueryable<UltraGridRow> GetQueryResult(IQueryable<UltraGridRow> queryableRow,
- string column, string key)
- {
- queryableRow = from q in queryableRow
- where q.Cells[column].Value.ToString().ToUpper() == key.ToUpper()
- select q;
- return queryableRow;
- }
- /// <summary>
- /// 根据主键快速查找子表的UltaGridRow数组(结果为父行下的所有子行)。
- /// </summary>
- /// <param name="band">子表band</param>
- /// <param name="columnNames">列名</param>
- /// <param name="keys">key值</param>
- /// <returns>UltraGridRow数组</returns>
- /// 2014年11月29日 15:25:36 cx
- public static UltraGridRow[] GetRowsWithKey(UltraGridChildBand band, string[] columnNames, string[] keys)
- {
- UltraGridRow[] rows = null;
- IQueryable<UltraGridRow> queryableRow = band.Rows.AsQueryable();
- if (columnNames.Length != keys.Length)
- {
- throw new Exception("列名数组与key值数组长度不一致!");
- }
- for (int i = 0; i < columnNames.Length; i++)
- {
- queryableRow = GetQueryResult(queryableRow, columnNames[i], keys[i]);
- }
- rows = queryableRow.ToArray();
- return rows;
- }
- /// <summary>
- /// 设置指定的列只读
- /// </summary>
- /// <param name="band"></param>
- /// <param name="columnKeys"></param>
- public static void SetColumnsActive(UltraGridBand band, params string[] columnKeys)
- {
- foreach (string columnKey in columnKeys)
- {
- if (band.Columns.Exists(columnKey))
- {
- band.Columns[columnKey].CellActivation = Activation.ActivateOnly;
- }
- }
- }
- /// <summary>
- /// 设置不包含在指定列中的列只读。
- /// </summary>
- /// <param name="band"></param>
- /// <param name="columnKeys"></param>
- public static void SetExcludeColumnsActive(UltraGridBand band, params string[] columnKeys)
- {
- foreach (UltraGridColumn gridColumn in band.Columns)
- {
- if (columnKeys.Contains(gridColumn.Key) == false)
- {
- gridColumn.CellActivation = Activation.ActivateOnly;
- }
- }
- }
- /// <summary>
- /// 初始化UltraGrid Card模式数据
- /// </summary>
- /// <param name="ultDataSource"></param>
- /// <param name="ultraGrid"></param>
- //public static void InitCardGrid(UltraDataSource ultDataSource, UltraGrid ultraGrid)
- //{
- // try
- // {
- // int iColumnsCount = ultDataSource.Band.Columns.Count;
- // object[] obj = new object[iColumnsCount];
- // ultDataSource.Rows.Clear();
- // for (int i = 0; i < ultDataSource.Band.Columns.Count; i++)
- // {
- // try
- // {
- // if (ultDataSource.Band.Columns[i].DataType == typeof(Bitmap) ||
- // ultDataSource.Band.Columns[i].DataType == typeof(Image))
- // obj[i] = null;
- // else if (ultDataSource.Band.Columns[i].DataType == typeof(DateTime))
- // obj[i] = DBNull.Value;
- // else if (ultDataSource.Band.Columns[i].DataType == typeof(decimal) ||
- // ultDataSource.Band.Columns[i].DataType == typeof(double) ||
- // ultDataSource.Band.Columns[i].DataType == typeof(Single))
- // obj[i] = 0;
- // else
- // obj[i] = "";
- // }
- // catch { }
- // try
- // {
- // ultraGrid.DisplayLayout.Bands[0].Columns[i].Header.Appearance.FontData.Bold = DefaultableBoolean.False;
- // }
- // catch { }
- // }
- // ultDataSource.Rows.Add(obj);
- // ultraGrid.UpdateData();
- // }
- // catch { }
- //}
- /// <summary>
- /// 隐藏指定的列
- /// </summary>
- /// <param name="gridBand">UltraGridBand</param>
- /// <param name="columnKeys">需要隐藏的列</param>
- public static void HidenColumns(UltraGridBand gridBand, params string[] columnKeys)
- {
- foreach (string columnKey in columnKeys)
- {
- if (gridBand.Columns.Exists(columnKey))
- {
- gridBand.Columns[columnKey].Hidden = true;
- }
- }
- }
- /// <summary>
- /// 隐藏不包含在指定列中的列。
- /// </summary>
- /// <param name="gridBand">UltraGridBand</param>
- /// <param name="columnKeys">不需要隐藏的列</param>
- public static void HidenExcludeColumns(UltraGridBand gridBand, params string[] columnKeys)
- {
- foreach (UltraGridColumn gridColumn in gridBand.Columns)
- {
- if (columnKeys.Contains(gridColumn.Key) == false)
- {
- gridColumn.Hidden = true;
- }
- }
- }
- /// <summary>
- /// UltraGridBand列设置全部只读。
- /// </summary>
- /// <param name="grid">UltraGridBand</param>
- public static void SetAllColumnsActive(UltraGrid grid)
- {
- foreach (UltraGridColumn column in grid.DisplayLayout.Bands[0].Columns)
- {
- column.CellActivation = Activation.ActivateOnly;
- }
- }
- /// <summary>
- /// 设置ultraGrid为不可编辑,如有选择Checked列Key为selectkey
- /// </summary>
- /// <param name="ulgrid">ultraGrid控件</param>
- public static void SetNoEnable(params Infragistics.Win.UltraWinGrid.UltraGrid[] ulgrids)
- {
- try
- {
- foreach (var ulgrid in ulgrids)
- {
- foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ulgrid.DisplayLayout.Bands)
- {
- band.Override.CellClickAction = CellClickAction.EditAndSelectText;//选中整行
- foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn Col in band.Columns)
- {
- Col.CellClickAction = CellClickAction.EditAndSelectText;
- if (Col.Style != Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox && Col.Key.ToLower() != "selectkey" && Col.Key.ToLower() != "check" && Col.Key.ToLower() != "isselect" && Col.Key.ToLower() != "checkbox")//选择复选框
- {
- if ((Col.Tag + "") == "AllowEdit") continue;
- Col.CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
- Col.SortIndicator = SortIndicator.Disabled;//不可以排序
- if (Col.DataType == typeof(DateTime?))
- {
- Col.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTime;
- }
- }
- else
- {
- Col.CellClickAction = CellClickAction.Edit;
- Col.CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- }
- }
- }
- }
- }
- catch
- {
- }
- }
- //取消其余勾选的行
- public static List<UltraGridRow> SetAllColumnsCheckByCode(UltraGrid grid,string Code,string checkName,Boolean IsBatch = false)
- {
- if (!IsBatch)
- {
- foreach (UltraGridRow row in UltraGridGetChooseRows(grid, checkName))
- {
- if (row.Cells[Code].Value.ToString() != grid.ActiveRow.Cells[Code].Value.ToString())
- {
- row.Cells[checkName].Value = false;
- }
- }
- }
- return UltraGridGetChooseRows(grid, checkName);
- }
- }
- }
|