기본 콘텐츠로 건너뛰기

Devexpress GridView 팁들

GridView 를 사용하다 보면 Cell 들을 Merge할 때가 발생합니다.
따라서, Cell Merge하는 방법은 아래와 같이 할 수 있습니다.

1. 세로 Merge
GridView.OptionsView.AllowCellMerge = true;
이와 같이 옵션을 설정하면, 기본적으로 Column 단위로 같은 Value 값을 가지는 Cell 단위로 Merge를 합니다.

GridColumn.OptionsColumn.AllowMerge = false;
이와 같이 할경우 해당 Column은 Merge를 실행하지 않습니다.

GridView.CellMerge Event를 통해 사용자 조건별로 Merge를 할 수 있습니다

void gridView1_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e)
{           
    if (e.Column.FieldName == "Q'TY")
    {
        int iValue1 = Convert.ToInt32(e.CellValue1);
        int iValue2 = Convert.ToInt32(e.CellValue2);
        e.Merge = true;
        e.Handled = true;
    }
}

2. 가로 Merge
가로 Merge 같은 경우는 GridView에서 옵션으로 기본 제공하지 않습니다.
따라서 해당 Cell을 강제적으로 다시 그려주는 등 여러 가지 Event를 사용해야 합니다.
따라서 Devexpress 에서 예제로 나오 있는 곳을 링크하는 것으로 대신합니다.

Merge cells Horizontally in GridView
https://www.devexpress.com/Support/Center/Example/Details/E2472/how-to-merge-cells-horizontally-in-gridview

==================
[ROW Cell Sum Exam 1]
https://documentation.devexpress.com/WindowsForms/DevExpress.XtraGrid.Views.Base.ColumnView.CustomUnboundColumnData.event

using DevExpress.XtraGrid.Views.Base; using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraGrid.Columns; private void Form1_Load(object sender, System.EventArgs e) { // ... gridControl1.ForceInitialize(); // Create an unbound column. GridColumn unbColumn = gridView1.Columns.AddField("Total"); unbColumn.VisibleIndex = gridView1.Columns.Count; unbColumn.UnboundType = DevExpress.Data.UnboundColumnType.Decimal; // Disable editing. unbColumn.OptionsColumn.AllowEdit = false; // Specify format settings. unbColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric; unbColumn.DisplayFormat.FormatString = "c"; // Customize the appearance settings. unbColumn.AppearanceCell.BackColor = Color.LemonChiffon;} // Returns the total amount for a specific row. decimal getTotalValue(GridView view, int listSourceRowIndex) { decimal unitPrice = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "UnitPrice")); decimal quantity = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "Quantity")); decimal discount = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "Discount")); return unitPrice * quantity * (1 - discount); } // Provides data for the Total column. private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) { GridView view = sender as GridView; if (e.Column.FieldName == "Total" && e.IsGetData) e.Value = getTotalValue(view, e.ListSourceRowIndex); }
}
================

[Link]
https://documentation.devexpress.com/WindowsForms/1477/Controls-and-Libraries/Data-Grid/Unbound-Columns

이 블로그의 인기 게시물

[C#] 연산자 목록(Operators)

[C#] C# 프로그램의 일반적인 구조(A skeleton of a C# program)

// A skeleton of a C# program  using System; namespace YourNamespace {     class YourClass     {     }     struct YourStruct     {     }     interface IYourInterface      {     }     delegate int YourDelegate();     enum YourEnum      {     }     namespace YourNestedNamespace     {         struct YourStruct          {         }     }     class YourMainClass     {         static void Main(string[] args)          {             //Your program starts here...         }     } } By Microsoft.MSDN :: .NET Guide Docs

[DB] 개발자가 알아야할 기본적인 쿼리 SELECT / INSERT / UPDATE / DELETE

DB관리자가 아니라면 관리에 관련된 지식보다는 DB의 자료를 활용하는 SQL(쿼리)문의 사용이 개발자에게는 더욱 중요하다. 가장 기본적인 뼈대만 정리해서 알아보자. 1. SELECT문 - 기본구조 1 2 3 4 5 6 [ WITH  < Sub Query >  ] SELECT  select_lsit [  FROM  table_source ] [  WHERE  search_condition ] [ GROUP  BY  group_by_expression ] [ HAVING search_condition ] [  ORDER   BY  order_expression [ ASC  |  DESC ] ] cs ----------- 1 2 3 SELECT  행_이름  FROM  테이블이름  WHERE  조건 cs ----------- [예제] 1 2 SELECT   *   FROM  employees; SELECT  department_id, department_name  FROM  departments; cs -- 데이터베이스 사용자(=스키마)조회 ( Oracle ) 1 SELECT   *   FROM  SYS.DBA_USERS; cs -- 테이블 중 "HR"이 소유한 테이블만 찾을떄 조건추가 -- SYS.DBA_TABLES == SYS.ALL_TABLES 1 SELECT   * ...