본문 바로가기
Winform

DevExpress BandedGrid

by 캡틴노랑이 2015. 9. 1.
반응형

 BandedGrid 코드로 구현할 때.

 

선행작업 디자이너에서 뷰를 BandedGrid로 변경


BandedGridColumn gca = (new BandedGridColumn()).SetGridColumn("a", 70, SHIMaskInfo.String, DevExpress.Utils.HorzAlignment.Center, EditMode.EditableAll);
BandedGridColumn gcb = (new BandedGridColumn()).SetGridColumn("b", 80, SHIMaskInfo.String, DevExpress.Utils.HorzAlignment.Center, EditMode.EditableAll);
BandedGridColumn gcc = (new BandedGridColumn()).SetGridColumn("c", 40, SHIMaskInfo.String, DevExpress.Utils.HorzAlignment.Center, EditMode.EditableAll);
BandedGridColumn gcd = (new BandedGridColumn()).SetGridColumn("d", 60, SHIMaskInfo.String, DevExpress.Utils.HorzAlignment.Center, EditMode.EditableAll);
BandedGridColumn gce = (new BandedGridColumn()).SetGridColumn("e", 25, SHIMaskInfo.String, DevExpress.Utils.HorzAlignment.Center, EditMode.EditableAll, chk);

GridBand gbA = (new GridBand()).SetBandedColumn("", 70, null);
GridBand gbB = (new GridBand()).SetBandedColumn("", 80, null);
GridBand gbE = (new GridBand()).SetBandedColumn("", 25, null);


bgView.Bands.Clear();
bgView.Bands.AddRange(new GridBand[] { gbA, gbB, gbE});

gbA.Columns.Add(gca);
gbA.Columns.Add(gcb);
gbB.Columns.Add(gcc);
gbB.Columns.Add(gcd);
gbE.Columns.Add(gce);


 public static ShiBandedGridColumn SetGridColumn(this ShiBandedGridColumn gridColumn,
            string fieldName, int width, SHIMaskInfo maskInfo, HorzAlignment hAlign, SHIEditMode editMode = SHIEditMode.EditableAll, RepositoryItem editor = null)
{
    gridColumn.Width = width;            
    if (hAlign != HorzAlignment.Default)
    {
        maskInfo.HAlign = hAlign;
    }
  
    gridColumn.AppearanceHeader.Options.UseTextOptions = true;
    gridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
    gridColumn.FieldName = fieldName;
    gridColumn.OptionsColumn.AllowEdit = (editMode != SHIEditMode.Disabled);
    gridColumn.ColumnEdit = editor;

    gridColumn.AppearanceCell.Options.UseTextOptions = true;
    if (maskInfo != null)
    {
        gridColumn.AppearanceCell.TextOptions.HAlignment = maskInfo.HAlign;
        gridColumn.DisplayFormat.FormatType = FormatType.Custom;
        gridColumn.DisplayFormat.FormatString = maskInfo.EditMask;
    }

    return gridColumn;            
}

public static GridBand SetBandedColumn(this GridBand gridBand, int width, DevExpress.XtraGrid.Views.BandedGrid.GridBand[] bands = null)
{    
    gridBand.Name = "";
    gridBand.Width = width;

    gridBand.AppearanceHeader.Options.UseTextOptions = true;
    gridBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;

    if (bands != null)
        gridBand.Children.AddRange(bands);

    return gridBand;
}



//그리드 헤더 정보 보기

bvwMaster.OptionsView.ShowBands = true;


반응형

댓글