* 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 |