본문 바로가기
Winform

인프라지스틱스 그리드 세팅

by 캡틴노랑이 2015. 11. 16.
반응형

인프라지스틱스 그리드 컬럼 세팅



public static class GridExt
{
  //컬럼 초기 컬럼 세팅
  public static void xAddColumn(this Infragistics.Win.UltraWinGrid.UltraGrid grd, string colName, string displayName, 
int width= 0, HAlign hAlign = HAlign.Center , VAlign vAlign = VAlign.Middle, bool hidden = false, Activation act =  Activation.NoEdit )
  {
      grd.DisplayLayout.Bands[0].Columns.Add(colName, displayName);
      grd.DisplayLayout.Bands[0].Columns[colName].Width = width;
      grd.DisplayLayout.Bands[0].Columns[colName].Hidden = hidden;
      grd.DisplayLayout.Bands[0].Columns[colName].Header.Appearance.TextHAlign = HAlign.Center;
      grd.DisplayLayout.Bands[0].Columns[colName].Header.Appearance.TextVAlign = VAlign.Middle;

      grd.DisplayLayout.Bands[0].Columns[colName].CellAppearance.TextHAlign = hAlign;
      grd.DisplayLayout.Bands[0].Columns[colName].CellAppearance.TextVAlign = vAlign;
  }

  //삭제 컬럼정의
 //그리드에 노출할 컬럼, 감출 컬럼을 datatable에 정의를 한다음에 그 정보 값으로 그리드에서 보여줄지 안보여줄지를 결정.
  public static void xHiddenColumn(this Infragistics.Win.UltraWinGrid.UltraGrid grd, DataTable dthiddenColumn)
  {
      foreach (DataRow dr in dthiddenColumn.Rows)
          grd.DisplayLayout.Bands[0].Columns[dr["ColumnNm"].ToString()].Hidden = 
dr["UseYN"].ToString().Equals("Y") ? false : true;           
  }

  public static void xSummarySetting(this Infragistics.Win.UltraWinGrid.UltraGrid grd)
  {
      //Summary
      grd.DisplayLayout.Override.SummaryDisplayArea = SummaryDisplayAreas.Default;
      grd.DisplayLayout.Override.SummaryFooterCaptionVisible = DefaultableBoolean.False;
      grd.DisplayLayout.Override.SummaryValueAppearance.FontData.Bold = DefaultableBoolean.True;
      grd.DisplayLayout.Override.SummaryFooterAppearance.BackColor = System.Drawing.SystemColors.GradientActiveCaption;

      grd.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Formula, null, SummaryPosition.Center);
      grd.DisplayLayout.Bands[0].Summaries[0].Appearance.BackColor =                                                                         System.Drawing.SystemColors.GradientActiveCaption;
      grd.DisplayLayout.Bands[0].Summaries[0].DisplayFormat = "{0}";
      grd.DisplayLayout.Bands[0].Summaries[0].SummaryDisplayArea = SummaryDisplayAreas.TopFixed |                                                                             SummaryDisplayAreas.RootRowsFootersOnly;
      grd.DisplayLayout.Bands[0].Summaries[0].Appearance.TextHAlign = HAlign.Center;
  }


  public static void xSummaryText(this Infragistics.Win.UltraWinGrid.UltraGrid grd, string text= "")
  {
      grd.DisplayLayout.Bands[0].Summaries[0].Formula = text;
      //http://stackoverflow.com/questions/24802947/how-to-force-ultragrid-column-formula-refresh
  }
}
반응형

댓글