Devexpress TreeList Multiple FooterRow - CustomDrawFooterCell

2024. 1. 30. 09:21· .Net Framework Standard/Component

* treelist 설정

int footerCount = 4;

int footerRowHeight = (treeList1.RowHeight * footerCount) + ((2 + 2) * footerCount);

this.treeList1.KeyFieldName = "ID";
this.treeList1.ParentFieldName = "ParentID";
this.treeList1.OptionsView.ShowSummaryFooter = true;
this.treeList1.FooterPanelHeight = footerRowHeight;

this.treeList1.CustomDrawFooterCell += treeList1_CustomDrawFooterCell;

this.treeList1.DataSource = Data1;
this.treeList1.PopulateColumns();

 

 

* CustomDrawFooterCell 구현

private void treeList1_CustomDrawFooterCell(object sender, DevExpress.XtraTreeList.CustomDrawFooterCellEventArgs e)
{
    if (sender is DevExpress.XtraTreeList.TreeList view)
    {

        if (view.DataSource == null)
        {
            e.Handled = false;
            return;
        }

        //e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; 

        switch (e.Column.FieldName)
        {
            case "Name":
                CustomDrawFooterName(e);
                break;

            case "Qty":
                CustomDrawFooterQty(e);
                break;
        } 

    }
}

 

 

* Method

// * Method
private void CustomDrawFooterQty(DevExpress.XtraTreeList.CustomDrawFooterCellEventArgs e)
{
    Rectangle rect;

    int term = 23;

    decimal qtySum1 = this.Data1.Sum(x => (decimal)x.Qty) + 100;  // 샘플 데이터

    decimal qtySum2 = this.Data1.Sum(x => (decimal)x.Qty) / 50;  // 샘플 데이터

    decimal qtySum3 = this.Data1.Sum(x => (decimal)x.Qty) / 25;  // 샘플 데이터

    decimal qtySum4 = this.Data1.Sum(x => (decimal)x.Qty) / 205;  // 샘플 데이터

    string text1 = qtySum1.ToString("#,##0.00");
    string text2 = qtySum2.ToString("#,##0.00");
    string text3 = qtySum3.ToString("#,##0.00");
    string text4 = qtySum4.ToString("#,##0.00");


    var font = e.Appearance.Font;

    var text1MaxWidth = TextRenderer.MeasureText(text1, font).Width + 10;
    var text2MaxWidth = TextRenderer.MeasureText(text2, font).Width + 10;
    var text3MaxWidth = TextRenderer.MeasureText(text3, font).Width + 10;
    var text4MaxWidth = TextRenderer.MeasureText(text4, font).Width + 10;

    rect = new Rectangle(new Point(e.Bounds.Right - text1MaxWidth, e.Bounds.Location.Y + 0), new Size(text1MaxWidth, 25));
    e.Painter.DrawCaption(e.Info, text1, font, e.Appearance.GetForeBrush(e.Cache), rect, e.Appearance.GetStringFormat()); 

    rect = new Rectangle(new Point(e.Bounds.Right - text2MaxWidth, e.Bounds.Location.Y + term), new Size(text2MaxWidth, 25));
    e.Painter.DrawCaption(e.Info, text2, font, e.Appearance.GetForeBrush(e.Cache), rect, e.Appearance.GetStringFormat());

    rect = new Rectangle(new Point(e.Bounds.Right - text3MaxWidth, e.Bounds.Location.Y + (term * 2)), new Size(text3MaxWidth, 25));
    e.Painter.DrawCaption(e.Info, text3, font, e.Appearance.GetForeBrush(e.Cache), rect, e.Appearance.GetStringFormat());

    rect = new Rectangle(new Point(e.Bounds.Right - text4MaxWidth, e.Bounds.Location.Y + (term * 3)), new Size(text4MaxWidth, 25));
    e.Painter.DrawCaption(e.Info, text4, font, e.Appearance.GetForeBrush(e.Cache), rect, e.Appearance.GetStringFormat());

    e.Handled = true;

}


private void CustomDrawFooterName(DevExpress.XtraTreeList.CustomDrawFooterCellEventArgs e)
{
    Rectangle rect;

    int term = 23;

    string text1 = "Excavation / Area        CM/SM";
    string text2 = "Conc. / Area        CM/SM";
    string text3 = "Re-bar / Conc.        KG/CM";
    string text4 = "Formwork / Conc.        SM/CM";
     

    var font = e.Appearance.Font;

    var text1MaxWidth = TextRenderer.MeasureText(text1, font).Width + 10;
    var text2MaxWidth = TextRenderer.MeasureText(text2, font).Width + 10;
    var text3MaxWidth = TextRenderer.MeasureText(text3, font).Width + 10;
    var text4MaxWidth = TextRenderer.MeasureText(text4, font).Width + 10;
      

    rect = new Rectangle(new Point(e.Bounds.Right - text1MaxWidth, e.Bounds.Location.Y + 0), new Size(text1MaxWidth, 25));
    e.Painter.DrawCaption(e.Info, text1, font, e.Appearance.GetForeBrush(e.Cache), rect, e.Appearance.GetStringFormat());


    var imag1 = global::WindowsFormsApp5.Properties.Resources.AnalyStr2; 
    var point1 = new Point(e.Bounds.Right - text1MaxWidth - 3 - (imag1.Width / 2), e.Bounds.Location.Y + 0 + ((e.Bounds.Height - imag1.Height) / 2));

    e.Graphics.DrawImage(imag1, point1);

    rect = new Rectangle(new Point(e.Bounds.Right - text2MaxWidth, e.Bounds.Location.Y + term), new Size(text2MaxWidth, 25));
    e.Painter.DrawCaption(e.Info, text2, font, e.Appearance.GetForeBrush(e.Cache), rect, e.Appearance.GetStringFormat());


    imag1 = global::WindowsFormsApp5.Properties.Resources.Area01;
    point1 = new Point(e.Bounds.Right - text2MaxWidth - 3 - (imag1.Width / 2), e.Bounds.Location.Y + term + ((e.Bounds.Height - imag1.Height) / 2));

    e.Graphics.DrawImage(imag1, point1);


    rect = new Rectangle(new Point(e.Bounds.Right - text3MaxWidth, e.Bounds.Location.Y + (term * 2)), new Size(text3MaxWidth, 25));
    e.Painter.DrawCaption(e.Info, text3, font, e.Appearance.GetForeBrush(e.Cache), rect, e.Appearance.GetStringFormat());


    imag1 = global::WindowsFormsApp5.Properties.Resources._16x16_Tank;
    point1 = new Point(e.Bounds.Right - text3MaxWidth - 3 - (imag1.Width / 2), e.Bounds.Location.Y + (term * 2) + ((e.Bounds.Height - imag1.Height) / 2));

    e.Graphics.DrawImage(imag1, point1);


    rect = new Rectangle(new Point(e.Bounds.Right - text4MaxWidth, e.Bounds.Location.Y + (term * 3)), new Size(text4MaxWidth, 25));
    e.Painter.DrawCaption(e.Info, text4, font, e.Appearance.GetForeBrush(e.Cache), rect, e.Appearance.GetStringFormat());



    imag1 = global::WindowsFormsApp5.Properties.Resources._3D_str;
    point1 = new Point(e.Bounds.Right - text4MaxWidth - 3 - (imag1.Width / 2), e.Bounds.Location.Y + (term * 3) + ((e.Bounds.Height - imag1.Height) / 2));

    e.Graphics.DrawImage(imag1, point1);

    e.Handled = true;

}

'.Net Framework Standard > Component' 카테고리의 다른 글

Devexpress GridContro/ TreeList Indicator Header에 버튼 추가  (0) 2024.07.03
[Devexpress] TreeListControl - Raise AfterCheckNode / BeforeCheckNode  (0) 2024.05.10
[Devexpress] BandedGridView에서 Header가 너무 긴 경우 Caption 표시  (0) 2024.01.15
[Devexpress]Form Control 및 Devexpress Ribbon의 TabView의 Perfomance  (0) 2016.08.01
'.Net Framework Standard/Component' 카테고리의 다른 글
  • Devexpress GridContro/ TreeList Indicator Header에 버튼 추가
  • [Devexpress] TreeListControl - Raise AfterCheckNode / BeforeCheckNode
  • [Devexpress] BandedGridView에서 Header가 너무 긴 경우 Caption 표시
  • [Devexpress]Form Control 및 Devexpress Ribbon의 TabView의 Perfomance
달빛에취하다
달빛에취하다
개발 관련 자료
달빛에취하다
삽질은 내 운명
달빛에취하다
전체
오늘
어제
GUEST
WRITE
ADMIN
  • 분류 전체보기 (72)
    • .Net Framework Standard (8)
      • WindowsApplication (7)
      • Silverlight (0)
      • ASP.NET (3)
      • Component (5)
    • .Net Core (3)
      • gRPC (2)
    • Database (8)
      • MSSQL (8)
      • MySQL (0)
      • Oracle (0)
    • Server (28)
      • Windows Server (15)
      • Linux (7)
      • NAS (1)
    • Etc (7)
      • Utility (3)

블로그 메뉴

  • 홈
  • 방명록

공지사항

인기 글

태그

  • url rewrite
  • TLS1.2
  • mssql
  • Fiddler
  • hyper-v
  • ad
  • TLS
  • docker
  • Windows Server
  • ARR
  • reverse proxy
  • ubuntu
  • DevExpress
  • C#
  • reverseproxy
  • ssl
  • powershell
  • VisualStudio
  • TreeList
  • GRPC
  • ServicePointManager.SecurityProtocol
  • Windows
  • m365
  • Microsoft365
  • ClickOnce
  • office365
  • 인증서
  • sql
  • https
  • IIS

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
달빛에취하다
Devexpress TreeList Multiple FooterRow - CustomDrawFooterCell
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.