기본 콘텐츠로 건너뛰기

8월, 2024의 게시물 표시

DevExpress / Grid Control - Row Separator

Row Separator with every row gridView1 -> Appearance -> RowSeparator -> BackColor gridView1 -> RowSeparatorHeight : 2 (example) Row Separator with every 10th row 1. gridView1 -> OptionsView -> ShowPreview : True 2. code private void gridView1_CustomDrawRowPreview(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e) {     int rowNumber = e.RowHandle + 1;     if(rowNumber % 10 == 0)     {         e.Cache.FillRectangle(e.Cache.GetSolidBrush(Color.Black), e.Bounds);         e.Handled = true;     } } private void gridView1_MeasurePreviewHeight(object sender, RowHeightEventArgs e) {     int rowNumber = e.RowHandle + 1;     if(rowNumber % 10 == 0)     {         e.RowHeight = 2;     }     else     {         e.RowHeight = 0;     } }

DevExpress / Grid Control - Change Cell Color

private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e) { GridView view = sender as GridView; // 특정 컬럼의 셀 스타일을 변경하고 싶을 때 if (e.Column.FieldName == "YourColumnName") { var cellValue = view.GetRowCellValue(e.RowHandle, e.Column).ToString(); // 특정 조건에 따라 스타일을 변경합니다. if (cellValue == "특정값") { e.Appearance.BackColor = Color.Yellow; // 배경색 e.Appearance.ForeColor = Color.Red; // 글자색 } else if (cellValue == "다른값") { e.Appearance.BackColor = Color.Green; e.Appearance.ForeColor = Color.White; } // 특정 행 번호와 컬럼 이름을 기반으로 셀을 식별합니다.  if (e.RowHandle == 2 && e.Column.FieldName == "YourColumnName")  {  // 조건이 충족되면 색상을 변경합니다.  e.Appearance.BackColor = Color.Yellow; // 배경색  e.Appearance.ForeColor = Color.Red; // 글자색  } // 필요에 따라 다른 조건을 추가합니다. } }  <example code> private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e) {     GridVi...

DevExpress / Grid Control - Set Column Style (Code) : Column Header Color, Column Header Font, Cell Font

private void SetColumnStyle(GridControl gc, Color clr) {     int nWidth = 300;     GridView view = gc.MainView as GridView;     for(int nIndex = 0; nIndex < view.Columns.Count; nIndex++)     {         view.Columns[nIndex].AppearanceHeader.BackColor = clr;         view.Columns[nIndex].AppearanceHeader.Font = new Font("Verdana", 14F,                               FontStyle.Bold);         view.Columns[nIndex].AppearanceCell.Font = new Font("Verdana", 12F, FontStyle.Bold);         if (nIndex == 0) nWidth = 200;         else nWidth = 300;         view.Columns[nIndex].Width = nWidth;     } }

DevExpress / Grid Control - Make columns in Run Time

private void makeGridView(GridControl gc, int rowCount) { DataTable dt = new DataTable(); dt.Columns.Add("STAGE NO."); dt.Columns.Add("작업상태"); dt.Columns.Add("타입"); dt.Columns.Add("프로세스"); dt.Columns.Add("STEP"); dt.Columns.Add("TRAY ID"); string channel = string.Empty; for (int i = 0; i < rowCount; i++) { channel = (i + 1).ToString(); dt.Rows.Add(new string[] { channel, "-", "-", "-", "-", "-" }); } gc.DataSource = dt; }