/// <summary> /// GetTextCore /// </summary> /// <param name="value"></param> /// <param name="formatInfo"></param> /// <param name="gridElement"></param> /// <returns></returns> protected override string GetTextCore(object value, CellTextFormatInfo formatInfo, GridElement gridElement) { DataCell cell = gridElement as DataCell; if (cell == null) { return(null); } if (cell.Value == null) { Xceed.Grid.DataRow row = cell.ParentRow as Xceed.Grid.DataRow; if (row == null) { return(null); } if (row.DetailGrids.Count == 0) { return(null); } MyDetailGrid detailGrid = row.DetailGrids[0] as MyDetailGrid; if (detailGrid == null) { return(null); } string functionName, fieldName, format, where; int level = -1; MySummaryRow.ExtractParameters(m_statisticsFormat, out functionName, out fieldName, out format, ref level, out where); cell.Value = Feng.Utils.ConvertHelper.ChangeType(MySummaryRow.GetVariableFunctionResult(detailGrid.GetSortedDataRows(true), functionName, fieldName, format, level, where), cell.ParentColumn.DataType); } return(base.GetTextCore(value, formatInfo, gridElement)); }
// Paints the foreground of the NumberedRowSelector. protected override void PaintForeground(GridPaintEventArgs e) { Xceed.Grid.DataRow dataRow = this.Row as Xceed.Grid.DataRow; // Only paint the datarows if (dataRow != null) { int number = 0; number = dataRow.Index + 1; // number = dataRow.ParentGroup.GetSortedDataRows( false ).IndexOf( dataRow ); // It is recommended to use the color returned from GetForeColorToPaint() // rather than the ForeColor property directly. using (SolidBrush brush = new SolidBrush(this.GetDisplayVisualStyle(Xceed.Grid.VisualGridElementState.InactiveSelection).ForeColor)) { Rectangle offsetRectangle = this.ClientRectangle; offsetRectangle.Offset(0, 1); e.Graphics.DrawString(number.ToString(), s_font, brush, offsetRectangle); } } else { // Not a DataRow, so let the base class paint itself. base.PaintForeground(e); } }
/// <summary> /// 加入某一行 /// </summary> /// <param name="grid"></param> /// <param name="dataRow"></param> public static Xceed.Grid.DataRow AddDataRow(this IGrid grid, System.Data.DataRow dataRow) { if (dataRow == null) { throw new ArgumentNullException("dataRow"); } Xceed.Grid.DataRow row = grid.DataRows.AddNew(); foreach (Xceed.Grid.Column column in grid.Columns) { string columnName = column.FieldName; if (dataRow.Table.Columns.Contains(columnName)) { if (grid.Columns[columnName].DataType.FullName == "System.String") { row.Cells[columnName].Value = dataRow[columnName].ToString(); } else { row.Cells[columnName].Value = dataRow[columnName] == System.DBNull.Value ? null : dataRow[columnName]; } } } row.EndEdit(); return(row); }
//初始化荷载组合表 public void InitLoadComForm() { MainForm mf = this.Owner as MainForm; Bmodel mm = mf.ModelForm.CurModel; BLoadCombTable lct = mm.LoadCombTable;//荷载组合表 gv_LC.FixedColumnSplitter.Visible = false; gv_LC.Columns.Add(new Column("名称", typeof(string))); gv_LC.Columns.Add(new Column("激活", typeof(string))); gv_LC.Columns.Add(new Column("地震组合", typeof(string))); gv_LC.Columns.Add(new Column("说明", typeof(string))); List <string> GenCom = lct.ComGen; for (int i = 0; i < GenCom.Count; i++) { BLoadComb curCom = lct.getLoadComb(LCKind.GEN, GenCom[i]);//取得荷载组合 Xceed.Grid.DataRow Row = gv_LC.DataRows.AddNew(); Row.Cells[0].Value = GenCom[i]; Row.Cells[1].Value = curCom.bACTIVE ? "激活":"钝化"; Row.Cells[2].Value = curCom.bES ? "是":"否"; Row.Cells[3].Value = curCom.DESC; Row.BackColor = System.Drawing.Color.DarkSeaGreen; Row.EndEdit(); } //gv_LC.ReadOnly = false; //gv_LC.Columns[2].CellEditorManager = new CheckBoxEditor(); //gv_LC.Columns[2].CellEditorDisplayConditions = CellEditorDisplayConditions.Always; }
/// <summary> /// TagGroups /// </summary> /// <param name="foundDataRow"></param> private void TagGroups(Xceed.Grid.DataRow foundDataRow) { // Make sure that each foundDataRow's parent groups have their GroupManagerRow's // BackColor set to the chosen highlight color. Group parentGroup = foundDataRow.ParentGroup as Group; Color color = Color.LightSteelBlue; while (parentGroup != null) { if (parentGroup.HeaderRows.Count > 0) { if (parentGroup.HeaderRows[0].BackColor != color) { parentGroup.HeaderRows[0].BackColor = color; } else { // The group is already tagged. That means that all its parent groups are // tagged too. We exit immediately. break; } } parentGroup = parentGroup.ParentGroup as Group; } }
private void SetNextSearchRow() { if (m_foundRows.Count <= 0) { return; } mCurrentSearchRow++; if (mCurrentSearchRow >= m_foundRows.Count) { mCurrentSearchRow = 0; } try { Xceed.Grid.DataRow row = m_foundRows[mCurrentSearchRow] as Xceed.Grid.DataRow; gridControl1.CurrentRow = row; row.BringIntoView(); } catch (System.Exception e) { // m_foundRows.Clear(); } }
/// <summary> /// Add a new string into the string table. /// </summary> private void AddString() { int locID = GetNextLocID(); if (locID == 0) { MessageBox.Show(this, "Oops. Could not get the next string ID.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew(); row.BeginEdit(); Xceed.Grid.Cell cell = row.Cells["_locID"]; cell.Value = locID; cell = row.Cells["String_text"]; cell.Value = "Insert Text Here"; cell = row.Cells["Language_Id"]; cell.Value = "0"; cell = row.Cells["subtitle"]; cell.Value = false; row.EndEdit(); // If we have the filter enabled, we are going to add the string to group so that it shows up // in the view to avoid the "Hey, where's my string I just added?" issues that surely will arise if (m_filtered) { // Make sure that each parent group of the found data row are expanded. if ((row.ParentGroup != null) && row.ParentGroup.Collapsed) { Group parentGroup = row.ParentGroup as Group; while (parentGroup != null) { parentGroup.Expand(); parentGroup = parentGroup.ParentGroup as Group; } } // Highlight the found data row by changing its back color // row.BackColor = Color.AliceBlue; // Highlight the found data row's parent groups by changing their // GroupManagerRow's back color. this.TagGroups(row); m_foundRows.Add(row); } gridControl1.UpdateGrouping(); gridControl1.Scroll(Xceed.Grid.ScrollDirection.BottomPage); gridControl1.SelectedRows.Clear(); gridControl1.SelectedRows.Add(row); gridControl1.CurrentRow = row; }
private void SetCheck(Xceed.Grid.DataRow row, bool value) { if (row.Cells[m_selectColumnName].ReadOnly) { return; } if (row.Cells[m_selectColumnName].IsBeingEdited) { row.Cells[m_selectColumnName].LeaveEdit(true); } row.Cells[m_selectColumnName].Value = value; }
private bool DeleteByRow(Xceed.Grid.DataRow row) { GridHelper.EndEditRow(row); bool rowAllowDelete = m_grid.AllowInnerDelete && m_cm.AllowDelete && Permission.AuthorizeByRule(ADInfoBll.Instance.GetGridRowInfo(m_grid.GridName).AllowDelete, row.Tag); if (rowAllowDelete) { m_cm.DisplayManager.Position = row.Index; return(m_cm.DeleteCurrent()); } return(false); }
/// <summary> /// /// </summary> public void FillFilterList() { if (!this.Visible) { return; } FilterRow filterRow = this.ParentRow as FilterRow; // Only build the list from the values under the FilterRow's hierarchical position. GroupBase groupBase = filterRow.ParentGroup; ReadOnlyDataRowList dataRows = groupBase.GetSortedDataRows(true); int dataRowsCount = dataRows.Count; DetailGrid parentGrid = groupBase as DetailGrid; if (parentGrid == null) { parentGrid = groupBase.ParentGrid; } //int cellsCount = parentGrid.Columns.Count; //object savedValue = this.Value; IFilter customFilter = m_filterItems.ContainsKey(s_customText) ? m_filterItems[s_customText] : null; // Clear the existing lists. this.ClearFilterList(); for (int i = 0; i < dataRowsCount; i++) { Xceed.Grid.DataRow dataRow = dataRows[i]; this.AddToFilterList(dataRow.Cells[this.FieldName]); } // Add Any and custom m_filterItems[s_anyText] = new AnyFilter(); m_filterItems[s_customText] = customFilter; // Fill editor and viewer this.FillViewerAndEditor(); //this.Value = savedValue; }
private bool IsDataRowIncluded(Xceed.Grid.DataRow selectedRow, IGrid grid) { foreach (Xceed.Grid.DataRow row in grid.DataRows) { if (row == selectedRow) { return(true); } foreach (MyDetailGrid detailGrid in row.DetailGrids) { if (IsDataRowIncluded(selectedRow, detailGrid)) { return(true); } } } return(false); }
internal static void AddDateItemToUnBoundGrid(this IBoundGrid grid, object dataItem) { GridInfo gridInfo = ADInfoBll.Instance.GetGridInfo(grid.GridName); if (!Authority.AuthorizeByRule(gridInfo.Visible)) { return; } GridRowInfo gridRowInfo = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); if (!Permission.AuthorizeByRule(gridRowInfo.Visible, dataItem)) { return; } Xceed.Grid.DataRow row = grid.DataRows.AddNew(); grid.SetDataRowsIListData(dataItem, row); row.EndEdit(); }
internal static void SetUnBoundGridDataBinding(this IBoundGrid grid) { try { grid.BeginInit(); grid.DataRows.Clear(); GridInfo gridInfo = ADInfoBll.Instance.GetGridInfo(grid.GridName); if (!Authority.AuthorizeByRule(gridInfo.Visible)) { return; } if (!string.IsNullOrEmpty(gridInfo.ReadOnly)) { grid.ReadOnly = Authority.AuthorizeByRule(gridInfo.ReadOnly); } GridRowInfo gridRowInfo = ADInfoBll.Instance.GetGridRowInfo(grid.GridName); foreach (object entity in grid.DisplayManager.Items) { if (!Permission.AuthorizeByRule(gridRowInfo.Visible, entity)) { continue; } Xceed.Grid.DataRow row = grid.DataRows.AddNew(); grid.SetDataRowsIListData(entity, row); row.EndEdit(); } } catch (Exception ex) { ExceptionProcess.ProcessWithNotify(ex); } finally { grid.EndInit(); } grid.AfterLoadData(); }
private bool CheckDetailGridAsc(Xceed.Grid.DataRow row) { foreach (DetailGrid detailGrid in row.DetailGrids) { for (int i = 0; i < detailGrid.DataRows.Count; ++i) { for (int j = 0; j < detailGrid.Columns.Count; ++j) { if (CheckCellValue(detailGrid.DataRows[i].Cells[j])) { SetCurrentCell(detailGrid.DataRows[i].Cells[j]); return(true); } } if (CheckDetailGridAsc(detailGrid.DataRows[i])) { return(true); } } } return(false); }
private bool CheckDetailGridDesc(Xceed.Grid.DataRow row) { foreach (DetailGrid detailGrid in row.DetailGrids) { for (int i = detailGrid.DataRows.Count - 1; i >= 0; --i) { if (CheckDetailGridDesc(detailGrid.DataRows[i])) { return(true); } for (int j = detailGrid.Columns.Count - 1; j >= 0; --j) { if (CheckCellValue(detailGrid.DataRows[i].Cells[j])) { SetCurrentCell(detailGrid.DataRows[i].Cells[j]); return(true); } } } } return(false); }
/// <summary> /// GetTextCore /// </summary> /// <param name="value"></param> /// <param name="formatInfo"></param> /// <param name="gridElement"></param> /// <returns></returns> protected override string GetTextCore(object value, CellTextFormatInfo formatInfo, GridElement gridElement) { DataCell cell = gridElement as DataCell; if (cell == null) { return(null); } if (cell.Value == null) { Xceed.Grid.DataRow row = cell.ParentRow as Xceed.Grid.DataRow; if (row == null) { return(null); } if (row.DetailGrids.Count == 0) { return(null); } IGrid grid = row.DetailGrids[0] as IGrid; if (grid == null) { return(null); } SummaryRow sumRow = grid.GetSummaryRow(); if (sumRow == null) { return(null); } cell.Value = ConvertHelper.ChangeType(sumRow.Cells[m_detailColumnName].Value, cell.ParentColumn.DataType); return(sumRow.Cells[m_detailColumnName].Value == null ? null : sumRow.Cells[m_detailColumnName].Value.ToString()); } else { return(base.GetTextCore(value, formatInfo, gridElement)); } }
private void SetCheck(Xceed.Grid.DataRow row, bool includeDetail, bool value) { SetCheck(row, value); if (includeDetail) { foreach (DetailGrid detailGrid in row.DetailGrids) { if (detailGrid.Collapsed) { // load detailGrid // Todo: now it's async, so ..... //detailGrid.Collapsed = false; } foreach (Xceed.Grid.DataRow subRow in detailGrid.DataRows) { if (detailGrid.Columns[m_selectColumnName] != null) { SetCheck(subRow, includeDetail, value); } } } } }
/// <summary> /// 刷新Row /// </summary> /// <param name="grid"></param> /// <param name="row"></param> public static void ResetRowData(this IBoundGrid grid, Xceed.Grid.DataRow row) { SetDataRowsIListData(grid, grid.DisplayManager.Items[row.Index], row); }
internal static void OnListChanged(ListChangedEventArgs e, IArchiveGrid grid) { if (grid.DisplayManager.InBatchOperation) { return; } try { grid.DisplayManager.BeginBatchOperation(); switch (e.ListChangedType) { case ListChangedType.ItemAdded: if (!grid.AddThrowInsertRow) { Xceed.Grid.DataRow row = grid.DataRows.AddNew(); grid.SetDataRowsIListData(grid.ControlManager.DisplayManager.CurrentItem, row); grid.SetGridRowCellPermissions(grid.DataRows[grid.ControlManager.DisplayManager.Position]); grid.SetGridRowCellColors(grid.DataRows[grid.ControlManager.DisplayManager.Position]); row.EndEdit(); grid.CurrentRow = row; } grid.ControlManager.DisplayManager.Position = grid.ControlManager.DisplayManager.Count - 1; // 通过InsertRow添加的时候,此时Xceed还未添加上Row ---??? // 确定:此时已经有DataRow if (grid.AddThrowInsertRow) { // 重新设置DataRow信息,因为可能在保存的时候有其他信息生成 // grid.CurrentRow = InsertRow grid.SetDataRowsIListData(grid.ControlManager.DisplayManager.CurrentItem, grid.DataRows[e.NewIndex]); grid.SetGridRowCellPermissions(grid.DataRows[e.NewIndex]); grid.SetGridRowCellColors(grid.DataRows[e.NewIndex]); } //this.ShowTitleRow(); break; case ListChangedType.ItemChanged: //bool inEdit = grid.DataRows[e.NewIndex].IsBeingEdited; //if (inEdit) //{ // grid.DataRows[e.NewIndex].CancelEdit(); //} grid.SetDataRowsIListData(grid.ControlManager.DisplayManager.Items[e.NewIndex], grid.DataRows[e.NewIndex]); grid.SetGridRowCellPermissions(grid.DataRows[e.NewIndex]); grid.SetGridRowCellColors(grid.DataRows[e.NewIndex]); // maybe there is a detailGrid, so load data in detailGrid grid.ControlManager.DisplayManager.OnPositionChanged(System.EventArgs.Empty); // 可能已经不能修改,不再进入修改状态 //if (inEdit) //{ // grid.DataRows[e.NewIndex].BeginEdit(); //} break; case ListChangedType.ItemDeleted: if (e.NewIndex >= 0 && e.NewIndex < grid.DataRows.Count) { grid.DataRows.RemoveAt(e.NewIndex); //this.ShowTitleRow(); } break; default: throw new NotSupportedException("not supported listChangedType"); } } finally { grid.DisplayManager.EndBatchOperation(); grid.DisplayManager.OnPositionChanged(System.EventArgs.Empty); } }
///// <summary> ///// ErrorIcon(all set icon in validationProvider) ///// </summary> //[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] //public System.Drawing.Icon ErrorIcon //{ // get { return m_grid.ErrorIcon; } // set // { // m_grid.ErrorIcon = value; // this.validationProvider1.Icon = value; // } //} #endregion #region "ContextMenu" private void tsmDeleteBatch_Click(object sender, EventArgs e) { Xceed.Grid.Row contextRow = m_grid.GridHelper.ContextRow; if (contextRow == null) { return; } Xceed.Grid.DetailGrid parentGrid = contextRow.ParentGrid; //int originalCnt = parentGrid.DataRows.Count; List <DataRow> list = new List <DataRow>(); if (m_grid.GridControl.SelectedRows.Contains(contextRow)) { if (!MessageForm.ShowYesNo("选定记录将要被删除,是否继续?", "确定", true)) { return; } foreach (Xceed.Grid.Row row in m_grid.GridControl.SelectedRows) { Xceed.Grid.DataRow dataRow = row as Xceed.Grid.DataRow; if (dataRow != null && dataRow.ParentGrid == parentGrid) { list.Add(dataRow); } } } else { if (!MessageForm.ShowYesNo("当前记录将要被删除,是否继续?", "确认", true)) { return; } Xceed.Grid.DataRow dataRow = contextRow as Xceed.Grid.DataRow; if (dataRow != null) { list.Add(dataRow); } } try { int unDeleteCnt = 0; foreach (Xceed.Grid.DataRow dataRow in list) { bool ret = DeleteByRow(dataRow); if (!ret) { unDeleteCnt++; } } //int nowCnt = parentGrid.DataRows.Count; if (unDeleteCnt > 0) { MessageForm.ShowInfo(string.Format("因权限原因,有{0}条记录未删除!", unDeleteCnt)); } } catch (Exception ex) { ExceptionProcess.ProcessWithNotify(ex); } }
/// <summary> /// 根据Entity的值设置row's cell值 /// </summary> /// <param name="grid"></param> /// <param name="entity"></param> /// <param name="row"></param> public static void SetDataRowsIListData(this IBoundGrid grid, object entity, Xceed.Grid.DataRow row) { // 如果同一个实体类,只是里面内容变了,重新设置不会设置成功 row.Tag = null; if (entity == null) { return; } row.Tag = entity; foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName)) { try { switch (info.GridColumnType) { case GridColumnType.Normal: if (row.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName)) { row.Cells[info.GridColumnName].Value = EntityScript.GetPropertyValue(entity, info.Navigator, info.PropertyName); } break; case GridColumnType.WarningColumn: row.Cells[info.GridColumnName].Value = (row.Cells[info.GridColumnName].ParentColumn as WarningColumn).Calculate(entity); break; case GridColumnType.StatColumn: { if (row.DetailGrids.Count == 0) { return; //throw new ArgumentException("stateColumn should has detailgrids."); } row.Cells[info.GridColumnName].Value = Feng.Utils.ConvertHelper.ChangeType( MySummaryRow.GetSummaryResult(row.DetailGrids[0].GetSortedDataRows(true), info.PropertyName), row.Cells[info.GridColumnName].ParentColumn.DataType); } break; case GridColumnType.ExpressionColumn: { //var info2 = info; //var row2 = row; //Feng.Async.AsyncHelper.Start(() => //{ // if (info2.PropertyName.Contains("%")) // { // return EntityScript.CalculateExpression(info2.PropertyName, entity); // } // else // { // return Feng.Utils.ProcessInfoHelper.TryExecutePython(info2.PropertyName, // new Dictionary<string, object>() { { "entity", entity }, { "row", row2 } }); // } //}, (result) => //{ // row2.Cells[info2.GridColumnName].Value = result; //}); if (info.PropertyName.Contains("%")) { row.Cells[info.GridColumnName].Value = EntityScript.CalculateExpression(info.PropertyName, entity); } else { row.Cells[info.GridColumnName].Value = ProcessInfoHelper.TryExecutePython(info.PropertyName, new Dictionary <string, object>() { { "entity", entity }, { "row", row } }); } } break; case GridColumnType.ImageColumn: { var i = Feng.Windows.ImageResource.Get(info.PropertyName); row.Cells[info.GridColumnName].Value = i == null ? null : i.Reference; } break; case GridColumnType.CheckColumn: { row.Cells[info.GridColumnName].Value = false; } break; case GridColumnType.NoColumn: case GridColumnType.SplitColumn: break; case GridColumnType.UnboundColumn: { try { row.Cells[info.GridColumnName].Value = Feng.Utils.ConvertHelper.ChangeType(info.PropertyName, Feng.Utils.ReflectionHelper.GetTypeFromName(info.TypeName)); } catch (Exception) { } } break; case GridColumnType.IndexColumn: { row.Cells[info.GridColumnName].Value = row.Index + 1; } break; default: throw new NotSupportedException("invalid GridColumnType of " + info.GridColumnType); } } catch (Exception ex) { ExceptionProcess.ProcessWithResume(new ArgumentException(info.PropertyName + " info is invalid!", ex)); } } }
/// <summary> /// /// </summary> /// <param name="dataSource"></param> /// <param name="dataMember"></param> /// <param name="hereLevel"></param> protected void SetDataRows(object dataSource, string dataMember, int hereLevel) { try { this.DisplayManager.BeginBatchOperation(); this.DataRows.Clear(); System.Collections.Generic.Dictionary <string, Xceed.Grid.DataRow> masterRows = new System.Collections.Generic.Dictionary <string, Xceed.Grid.DataRow>(); DataTable dt = dataSource as DataTable; if (dt == null) { IEnumerable list = dataSource as IEnumerable; if (list != null) { foreach (object entity in list) { for (int i = 0; i <= hereLevel; ++i) { Xceed.Grid.DataRow gridRow = null; if (i < hereLevel || i == 0) { if (!masterRows.ContainsKey(GetListValue(entity, m_levelParents[i]).ToString())) { if (i == 0) { gridRow = this.DataRows.AddNew(); masterRows[GetListValue(entity, m_levelParents[i]).ToString()] = gridRow; } else { gridRow = masterRows[GetListValue(entity, m_levelParents[i - 1]).ToString()].DetailGrids[0].DataRows.AddNew(); } } else { gridRow = masterRows[GetListValue(entity, m_levelParents[i]).ToString()]; } } else { gridRow = masterRows[GetListValue(entity, m_levelParents[i - 1]).ToString()].DetailGrids[0].DataRows.AddNew(); } gridRow.EndEdit(); gridRow.Tag = entity; foreach (string columnName in m_gridColumnNames[i]) { GridColumnInfo info = m_infos[columnName]; switch (info.GridColumnType) { case GridColumnType.Normal: if (gridRow.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName)) { gridRow.Cells[info.GridColumnName].Value = EntityScript.GetPropertyValue(entity, info.Navigator, info.PropertyName); } break; case GridColumnType.WarningColumn: gridRow.Cells[info.GridColumnName].Value = (gridRow.Cells[info.GridColumnName].ParentColumn as WarningColumn).Calculate(entity); break; case GridColumnType.StatColumn: case GridColumnType.ExpressionColumn: case GridColumnType.ImageColumn: case GridColumnType.SplitColumn: case GridColumnType.CheckColumn: case GridColumnType.NoColumn: break; default: throw new NotSupportedException("invalid GridColumnType of " + info.GridColumnType); } // //gridRow.Cells[columnName].Value = GetListValue(entity, columnName); } gridRow.EndEdit(); } } } Dictionary <Xceed.Grid.DataRow, bool> m_processdRows = new Dictionary <Xceed.Grid.DataRow, bool>(); foreach (object entity in list) { for (int i = 0; i < hereLevel; ++i) { Xceed.Grid.DataRow gridRow = masterRows[GetListValue(entity, m_levelParents[i]).ToString()]; if (!m_processdRows.ContainsKey(gridRow)) { m_processdRows[gridRow] = true; } else { continue; } foreach (string columnName in m_gridColumnNames[i]) { GridColumnInfo info = m_infos[columnName]; switch (info.GridColumnType) { case GridColumnType.StatColumn: { if (gridRow.DetailGrids.Count == 0) { throw new ArgumentException("stateColumn should has detailgrids."); } gridRow.Cells[info.GridColumnName].Value = Feng.Utils.ConvertHelper.ChangeType( MySummaryRow.GetSummaryResult(gridRow.DetailGrids[0].GetSortedDataRows(true), info.PropertyName), gridRow.Cells[info.GridColumnName].ParentColumn.DataType); } break; } } } } } else { foreach (System.Data.DataRow dataRow in dt.Rows) { for (int i = 0; i <= hereLevel; ++i) { Xceed.Grid.DataRow gridRow = null; if (i < hereLevel || i == 0) { if (!masterRows.ContainsKey(dataRow[m_levelParents[i]].ToString())) { if (i == 0) { gridRow = this.DataRows.AddNew(); masterRows[dataRow[m_levelParents[i]].ToString()] = gridRow; } else { gridRow = masterRows[dataRow[m_levelParents[i - 1]].ToString()].DetailGrids[0].DataRows.AddNew(); } } else { gridRow = masterRows[dataRow[m_levelParents[i]].ToString()]; } } else { gridRow = masterRows[dataRow[m_levelParents[i - 1]].ToString()].DetailGrids[0].DataRows.AddNew(); } // 如果在下方EndEdit,DetailGrid可能不会生成,不知原因 gridRow.EndEdit(); gridRow.Tag = dataRow; foreach (string columnName in m_gridColumnNames[i]) { GridColumnInfo info = m_infos[columnName]; switch (info.GridColumnType) { case GridColumnType.Normal: { if (!dt.Columns.Contains(columnName)) { continue; } if (gridRow.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName)) { gridRow.Cells[info.GridColumnName].Value = (dataRow[columnName] == System.DBNull.Value ? null : Feng.Utils.ConvertHelper.TryIntToEnum(dataRow[columnName], GridColumnInfoHelper.CreateType(m_infos[columnName]))); } } break; case GridColumnType.WarningColumn: throw new NotSupportedException("warning column is not supported in datarow."); case GridColumnType.StatColumn: case GridColumnType.ExpressionColumn: case GridColumnType.ImageColumn: case GridColumnType.SplitColumn: case GridColumnType.CheckColumn: case GridColumnType.NoColumn: break; default: throw new NotSupportedException("invalid GridColumnType of " + info.GridColumnType); } } gridRow.EndEdit(); } } Dictionary <Xceed.Grid.DataRow, bool> m_processdRows = new Dictionary <Xceed.Grid.DataRow, bool>(); foreach (System.Data.DataRow dataRow in dt.Rows) { for (int i = 0; i < hereLevel; ++i) { Xceed.Grid.DataRow gridRow = masterRows[dataRow[m_levelParents[i]].ToString()]; if (!m_processdRows.ContainsKey(gridRow)) { m_processdRows[gridRow] = true; } else { continue; } foreach (string columnName in m_gridColumnNames[i]) { GridColumnInfo info = m_infos[columnName]; switch (info.GridColumnType) { case GridColumnType.StatColumn: { if (gridRow.DetailGrids.Count == 0) { throw new ArgumentException("stateColumn should has detailgrids."); } gridRow.Cells[info.GridColumnName].Value = Feng.Utils.ConvertHelper.ChangeType( MySummaryRow.GetSummaryResult(gridRow.DetailGrids[0].GetSortedDataRows(true), info.PropertyName), gridRow.Cells[info.GridColumnName].ParentColumn.DataType); } break; } } } } } this.AfterLoadData(); } finally { this.DisplayManager.EndBatchOperation(); this.DisplayManager.OnPositionChanged(System.EventArgs.Empty); } }
/// <summary> /// 输出指定单元指定截面的设计内力 /// </summary> /// <param name="iEle">单元号</param> /// <param name="loc">截面位置</param> /// <param name="mm">模型数据</param> /// <param name="cm">设计数据</param> public void printDesignForcebyEle(int iEle, int loc, ref Bmodel mm, ref BCheckModel cm) { List <string> coms = mm.LoadCombTable.ComSteel;//钢结构设计组合表 string sLoc = null; switch (loc) { case 0: sLoc = "I"; break; case 1: sLoc = "1/8"; break; case 2: sLoc = "2/8"; break; case 3: sLoc = "3/8"; break; case 4: sLoc = "4/8"; break; case 5: sLoc = "5/8"; break; case 6: sLoc = "6/8"; break; case 7: sLoc = "7/8"; break; case 8: sLoc = "J"; break; } //指定地震工况 string LcEx = "SRSS3"; string LcEy = "SRSS4"; string LcEz = "Ez"; List <string> LcEs = new List <string>() { LcEx, LcEy, LcEz }; foreach (string com in coms) { BLoadComb curComb = mm.LoadCombTable.getLoadComb(LCKind.STEEL, com); //正常组合 BLoadComb Comb_N = curComb.Clone() as BLoadComb; BLoadComb Comb_M = curComb.Clone() as BLoadComb; //弯矩调整组合 BLoadComb Comb_V = curComb.Clone() as BLoadComb; //剪力调整组合 if (!curComb.bACTIVE) { continue; } ElemForce EFcom = mm.CalElemForceComb(curComb, iEle); Xceed.Grid.DataRow curRow = gc_Table.DataRows.AddNew(); //添加数据行 if (cm.QuakeAdjustFacors.ContainsKey(iEle) & curComb.hasLC(LcEs)) //如果为地震组合且有放大 { BQuakeAdjustFactor qaf = cm.QuakeAdjustFacors[iEle]; //放大系数 Comb_N.magnifyLc(LcEs, qaf.N_LC); //组合前放大 Comb_N.magnifyComb(qaf.N_COM); //组合后放大 Comb_M.magnifyLc(LcEs, qaf.M_LC); //组合前放大 Comb_M.magnifyComb(qaf.M_COM); //组合后放大 Comb_V.magnifyLc(LcEs, qaf.V_LC); //组合前放大 Comb_V.magnifyComb(qaf.V_COM); //组合后放大 curRow.BackColor = Color.AliceBlue; } ElemForce EFcom_N = mm.CalElemForceComb(Comb_N, iEle); ElemForce EFcom_M = mm.CalElemForceComb(Comb_M, iEle); ElemForce EFcom_V = mm.CalElemForceComb(Comb_V, iEle); curRow.Cells[0].Value = iEle; curRow.Cells[1].Value = sLoc; curRow.Cells[2].Value = com; curRow.Cells[3].Value = Math.Round(EFcom_N[loc].N / 1000, 1); curRow.Cells[4].Value = Math.Round(EFcom_V[loc].Vy / 1000, 1); curRow.Cells[5].Value = Math.Round(EFcom_V[loc].Vz / 1000, 1); curRow.Cells[6].Value = Math.Round(EFcom[loc].T / 1000, 1); curRow.Cells[7].Value = Math.Round(EFcom_M[loc].My / 1000, 1); curRow.Cells[8].Value = Math.Round(EFcom_M[loc].Mz / 1000, 1); curRow.EndEdit();//完成数据行编辑 //if (cm.QuakeAdjustFacors.ContainsKey(iEle) & curComb.hasLC(LcEs))//如果为地震组合且有放大 //{ // //调整前数据 // Xceed.Grid.DataRow curRowN = gc_Table.DataRows.AddNew();//添加数据 // curRowN.BackColor = Color.Red; // curRowN.Cells[0].Value = iEle; // curRowN.Cells[1].Value = sLoc; // curRowN.Cells[2].Value = com; // curRowN.Cells[3].Value = EFcom[loc].N / 1000; // curRowN.Cells[4].Value = EFcom[loc].Vy / 1000; // curRowN.Cells[5].Value = EFcom[loc].Vz / 1000; // curRowN.Cells[6].Value = EFcom[loc].T / 1000; // curRowN.Cells[7].Value = EFcom[loc].My / 1000; // curRowN.Cells[8].Value = EFcom[loc].Mz / 1000; // curRowN.EndEdit();//完成数据行编辑 //} } }
/// <summary> /// /// </summary> public void ApplyFilters() { List <Xceed.Grid.DataRow> list = new List <DataRow>(); int rowsCount = this.ParentGrid.GetSortedDataRowCount(false); int cellsCount = this.Cells.Count; bool hasFilter = false; for (int i = 0; i < rowsCount; ++i) { bool?ret = null; Xceed.Grid.DataRow row = this.ParentGrid.GetSortedDataRows(false)[i]; for (int j = 0; j < cellsCount; j++) { if (!this.Cells[j].Visible) { continue; } if (this.Cells[j].ReadOnly) { continue; } if (!(this.Cells[j].CellEditorManager is FilterEditor)) { continue; } string toFilter = (string)this.Cells[j].Value; if (string.IsNullOrEmpty(toFilter)) { continue; } hasFilter = true; string cellText = row.Cells[j].GetDisplayText(); if (cellText.Contains(toFilter, StringComparison.OrdinalIgnoreCase)) { if (!ret.HasValue) { ret = true; } } else { ret = false; break; } } if (ret.HasValue && ret.Value) { list.Add(row); } } if (list.Count > 0) { if (this.ParentGrid.Columns[TextFilterSelectColumnName].SortDirection != SortDirection.Ascending) { m_savedSortedColumns.Clear(); foreach (Column i in this.ParentGrid.SortedColumns) { m_savedSortedColumns.Add(i); } } this.ParentGrid.SortedColumns.Clear(); this.ParentGrid.Columns[TextFilterSelectColumnName].SortDirection = SortDirection.Ascending; foreach (Xceed.Grid.DataRow row in this.ParentGrid.DataRows) { if (list.Contains(row)) { row.Cells[TextFilterSelectColumnName].Value = false; row.Font = new Font(row.Font, FontStyle.Bold); } else { row.Cells[TextFilterSelectColumnName].Value = true; row.Font = new Font(row.Font, FontStyle.Regular); } } } else { this.ParentGrid.SortedColumns.Clear(); foreach (var i in m_savedSortedColumns) { this.ParentGrid.SortedColumns.Add(i); } foreach (Xceed.Grid.DataRow row in this.ParentGrid.DataRows) { row.Cells[TextFilterSelectColumnName].Value = true; row.Font = new Font(row.Font, FontStyle.Regular); } if (hasFilter) { ServiceProvider.GetService <IMessageBox>().ShowInfo("无符合条件的记录。"); } } }