Beispiel #1
0
 private void DrawChooseGroupRowEventMethod(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e)
 {
     e.Painter.DrawObject(e.Info);
     if (this.AllowChooseGroup)
     {
         var repositoryCheck = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
         repositoryCheck.Caption        = "";
         repositoryCheck.GlyphAlignment = DevExpress.Utils.HorzAlignment.Far;
         var info    = repositoryCheck.CreateViewInfo() as DevExpress.XtraEditors.ViewInfo.CheckEditViewInfo;
         var painter = repositoryCheck.CreatePainter() as DevExpress.XtraEditors.Drawing.CheckEditPainter;
         int start   = this.GetDataRowHandleByGroupRowHandle(e.RowHandle);
         int end     = ((GroupSummaryDataType)this.GetGroupSummaryValue(e.RowHandle, GroupChooseNeedSummary)).end;
         int count   = ((GroupSummaryDataType)this.GetGroupSummaryValue(e.RowHandle, GroupChooseNeedSummary)).choosecount;
         if (count == end - start + 1)
         {
             info.EditValue = true;
         }
         else if (count == 0)
         {
             info.EditValue = false;
         }
         else
         {
             info.EditValue = null;
         }
         info.Bounds = e.Bounds;
         info.CalcViewInfo(e.Graphics);
         groupCheckBoxPosition = e.Bounds.Left + e.Bounds.Width;
         var args = new DevExpress.XtraEditors.Drawing.ControlGraphicsInfoArgs(info, new DevExpress.Utils.Drawing.GraphicsCache(e.Graphics), e.Bounds);
         painter.Draw(args);
         args.Cache.Dispose();
     }
     e.Handled = true;
 }
Beispiel #2
0
        /// <summary>
        /// 列头画多选框
        /// </summary>
        /// <param name="e"></param>
        /// <param name="chk"></param>

        private static void DrawCheckBox(DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventArgs e, bool chk)
        {
            try
            {
                DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit repositoryCheck = e.Column.ColumnEdit as DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit;
                if (repositoryCheck != null)
                {
                    System.Drawing.Graphics  g = e.Graphics;
                    System.Drawing.Rectangle r = e.Bounds;

                    DevExpress.XtraEditors.ViewInfo.CheckEditViewInfo      info;
                    DevExpress.XtraEditors.Drawing.CheckEditPainter        painter;
                    DevExpress.XtraEditors.Drawing.ControlGraphicsInfoArgs args;
                    info = repositoryCheck.CreateViewInfo() as DevExpress.XtraEditors.ViewInfo.CheckEditViewInfo;

                    painter        = repositoryCheck.CreatePainter() as DevExpress.XtraEditors.Drawing.CheckEditPainter;
                    info.EditValue = chk;
                    info.Bounds    = r;
                    info.CalcViewInfo(g);
                    args = new DevExpress.XtraEditors.Drawing.ControlGraphicsInfoArgs(info, new DevExpress.Utils.Drawing.GraphicsCache(g), r);
                    painter.Draw(args);
                    args.Cache.Dispose();
                }
            }
            catch
            {
            }
        }
Beispiel #3
0
 private void CustomDrawChooseColumnHeaderEventMethod(object sender, DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventArgs e)
 {
     if (this.AllowChoose && e.Column != null && e.Column.FieldName == ChooseColumnName)
     {
         e.Info.InnerElements.Clear();
         e.Info.Caption = "";
         e.Painter.DrawObject(e.Info);
         var repositoryCheck = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
         repositoryCheck.Caption = "";
         var info    = repositoryCheck.CreateViewInfo() as DevExpress.XtraEditors.ViewInfo.CheckEditViewInfo;
         var painter = repositoryCheck.CreatePainter() as DevExpress.XtraEditors.Drawing.CheckEditPainter;
         if (this.ChooseCount == this.DataRowCount)
         {
             info.EditValue = true;
         }
         else if (this.ChooseCount > 0)
         {
             info.EditValue = null;
         }
         else
         {
             info.EditValue = false;
         }
         info.Bounds = e.Bounds;
         info.CalcViewInfo(e.Graphics);
         var args = new DevExpress.XtraEditors.Drawing.ControlGraphicsInfoArgs(info, new DevExpress.Utils.Drawing.GraphicsCache(e.Graphics), e.Bounds);
         painter.Draw(args);
         args.Cache.Dispose();
         e.Handled = true;
     }
 }