컴퓨터/DX C#

[DX] DevExpress.XtraGrid.Views.BandedGrid 사용하기

호마 2015. 4. 15. 14:52

1. 폼의 디자이너에서 도구 상자>DX.13.1: Data & Analytics 그룹의 GridControl 컨트롤을 폼에 추가한다.


2. 추가한 컨트롤의 Run Designer 버튼 클릭


3. Main>Views 페이지에서는 View의 속성을 변경할 수 있다.

 중앙에는 이 GridControl에 속해있는 GridView 목록을 보여준다.

 해당하는 GridView의 (Click here to change view) 글자를 클릭하면 컨텍스트 메뉴가 도시되는데,

 이 메뉴에서 Convert To > BandedGridView 를 선택하면 컨트롤이 변경된다.


4. Main>Columns 페이지로 들어가면 Column을 추가할 수 있다.

GridView에 추가할 Column을 생성한다.


아래에 변경 할만한 속성들을 정리해 보았다. 


Appearence-Caption = [보여지는 텍스트]

Data-FieldName = [DataSource와 매칭되는 클래스의 변수 이름]

Option-OptionColumn-AllowMove = false (이동 금지)

Option-OptionColumn-AllowSort = false (정렬 금지)

Option-OptionColumn-ReadOnly = true (변경 금지)


5. Main>Bands 페이지로 들어가면 Band와 Column을 추가하고 배치할 수 있다.

먼저 Band를 하나 추가한 다음, 미리 만들어둔 Column을 목록에서 드래그하여 추가한다.

참고: Customizing the Band Layout.

 

6. DX디자이너를 닫는다.

다음 코드는 EventGridView 클래스를 선언하여 FillEventGrid 함수로 GridView에 데이터를 추가한다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class EventGridView
{
    public EventGridView()
    {
        this.image = "";
        this.eventType = "";
        this.name = "";
        this.date = "";
        this.X = "";
        this.Y = "";
        this.Z = "";
        this.auto = false;
    }  
 
    public string image { get; set; }
    public string eventType { get; set; }
    public string name { get; set; }
    public string date { get; set; }
    public string X { get; set; }
    public string Y { get; set; }
    public string Z { get; set; }
    public bool auto { get; set; }
 
    public void Set(EventGridView info)
    {
        this.image = info.image;
        this.eventType = info.eventType;
        this.name = info.name;
        this.date = info.date;
        this.X = info.X;
        this.Y = info.Y;
        this.Z = info.Z;
        this.auto = info.auto;
    }
}
 
private void FillEventGrid()
{
    EventGridView info = new EventGridView();
    info.image = "(캡쳐)";
    info.name = "창고 앞 물체 인식";
    info.eventType = "움직임 발생";
    info.date = "2015/04/16(목) 06:45:34";
    info.X = "127.050255";
    info.Y = "37.541353";
    info.Z = "0";
    info.auto = false;
 
    List<EventGridView> infolist = new List<EventGridView>();
    infolist.Add(info);
 
    this.eventGrid.DataSource = infolist;
    this.bandedGridView1.BestFitColumns();
}
cs