개발 노트

데이터그리드뷰 특정값 열 색상채우기 본문

프로그래밍/C#

데이터그리드뷰 특정값 열 색상채우기

알 수 없는 사용자 2022. 3. 4. 14:04

 

private void dbView_CellFormatting(object sender,
DataGridViewCellFormattingEventArgs e) {
{
      //특정값을 가진 열을 좀 다르게 보여주고 싶을 때
      if (e.ColumnIndex == 1)
      {
            if (e.Value != null)
            {
                 string text = e.Value.ToString();
                 if (text.Contains("텍스트"))
                 {
                      e.CellStyle.ForeColor = Color.Red;
                      e.CellStyle.SelectionForeColor = Color.Red;
                  }
              }
         }
  }




 

참고링크

https://blueasa.tistory.com/332