private void GridControl_PaintEx(object sender, DevExpress.XtraGrid.PaintExEventArgs e) { GridViewInfo gvi = View.GetViewInfo() as GridViewInfo; GridRowInfo gri = gvi.RowsInfo.FindRow(ItemRowHandle()); if (gri == null) { return; } Rectangle drawRect = gri.DataBounds; drawRect.Height--; e.Cache.FillRectangle(gri.Appearance.GetBackBrush(e.Cache), drawRect); drawRect.Inflate(-3, -3); e.Cache.DrawString(Text, gri.Appearance.Font, gri.Appearance.GetForeBrush(e.Cache), drawRect, gri.Appearance.GetStringFormat()); }
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(); }
protected virtual void CalcButtonInfo() { MyGridView gv = View as MyGridView; if (gv.SaveButton != null) { int rowsCount = RowsLoadInfo.ResultRows.Count; if (RowsInfo.Count > 0 && RowsInfo.Count == rowsCount && (RowsInfo[RowsInfo.Count - 1].Bounds.Bottom) < ViewRects.Rows.Bottom) { GridRowInfo gri = RowsInfo[RowsInfo.Count - 1]; if (buttonInfo == null) { buttonInfo = new EditorButtonObjectInfoArgs(gv.SaveButton, gv.SaveButton.Appearance); } buttonInfo.Bounds = new Rectangle(gri.Bounds.X + 2, gri.Bounds.Bottom + 2, 40, 18); return; } } buttonInfo = null; }
private static void SetDetailGridsReadOnly(IWindowControlManager cm, GridRowInfo rowInfo) { // DetailGrid if (!string.IsNullOrEmpty(rowInfo.DetailGridReadOnly)) { object[] ss = ParamCreatorHelper.TryGetParams(rowInfo.DetailGridReadOnly); foreach (object s in ss) { //string[] sss = s.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); object[] sss = ParamCreatorHelper.TryGetParams((string)s); // 第一个是GridName,第二个是权限 if (sss.Length == 2) { foreach (IStateControl sc in cm.StateControls) { ArchiveUnboundGrid detailGrid = sc as ArchiveUnboundGrid; if (detailGrid != null && detailGrid.GridName == (string)sss[0]) { detailGrid.ReadOnly = Permission.AuthorizeByRule((string)sss[1], cm.DisplayManager.CurrentItem); // 不用重新设置,RowCell的ReadOnly在读取数据后就设置了。 // 在SetDataBinding时,凡是ReadOnly=true的都设置好。 // 不需要,无DataRow,不用设置。 Column.ReadOnly已经设置好了 //if (!detailGrid.ReadOnly) //{ // // 设置detailGrid的Row,Cell属性 // ArchiveUnboundGrid.SetGridRowCellPermissions(detailGrid); //} } } } else if (sss.Length == 1) { foreach (IStateControl sc in cm.StateControls) { ArchiveUnboundGrid detailGrid = sc as ArchiveUnboundGrid; if (detailGrid != null) { detailGrid.ReadOnly = Permission.AuthorizeByRule((string)sss[0], cm.DisplayManager.CurrentItem); } } } else { throw new ArgumentException("DetailGridReadOnly must have 2 or 1 param!"); } } } }
private static void SetDetailGridsAllowInsert(IWindowControlManager cm, GridRowInfo rowInfo) { // DetailGrid AllowInsert if (!string.IsNullOrEmpty(rowInfo.DetailGridAllowInsert)) { object[] ss = ParamCreatorHelper.TryGetParams(rowInfo.DetailGridAllowInsert); foreach (object s in ss) { //string[] sss = s.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); object[] sss = ParamCreatorHelper.TryGetParams((string)s); // 第一个是GridName,第二个是权限 if (sss.Length == 2) { foreach (IStateControl sc in cm.StateControls) { ArchiveUnboundGrid detailGrid = sc as ArchiveUnboundGrid; if (detailGrid != null && detailGrid.GridName == (string)sss[0]) { if (detailGrid.InsertionRow != null) { detailGrid.AllowInnerInsert = Permission.AuthorizeByRule((string)sss[1], cm.DisplayManager.CurrentItem); detailGrid.InsertionRow.Visible = detailGrid.AllowInnerInsert; } } } } else if (sss.Length == 1) { foreach (IStateControl sc in cm.StateControls) { ArchiveUnboundGrid detailGrid = sc as ArchiveUnboundGrid; if (detailGrid != null) { if (detailGrid.InsertionRow != null) { detailGrid.AllowInnerInsert = Permission.AuthorizeByRule((string)sss[0], cm.DisplayManager.CurrentItem); detailGrid.InsertionRow.Visible = detailGrid.AllowInnerInsert; } } } } else { throw new ArgumentException("DetailGridAllowInsert must have 2 or 1 param!"); } } } else { SetDetailGridsAllowInsertVisible(cm, true); } }