안녕하세요, 저는 Windows Form 응용 프로그램에서 작업하고 있지만 문제가 있습니다. 우리는 데이터 그리드보기를 사용하고 있고 행 하나가 비어있는 경우 행을 강조 표시하고 싶습니다. 이유는 모르지만 코드는 작동하지 않습니다. 여기 내 코드;DataGridView 행 색이 변경되지 않습니다.
public Form1()
{
InitializeComponent();
var dtCombined = PopulateCombinedDatatable();
dataGridView.DataSource = dtCombined;
HighlateIfEmpty();
}
public string[] FindFilePath()
{
//OPERATIONS
}
public DataTable PopulateCombinedDatatable()
{
//MY OPERATIONS
}
public void HighlateIfEmpty()
{
foreach (DataGridViewRow row in dataGridView.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
if ((string)cell.Value == string.Empty)
{
cell.Style.BackColor = Color.BlueViolet;
cell.Style.SelectionBackColor = Color.Aquamarine;
row.DefaultCellStyle.SelectionBackColor = Color.BlueViolet;
row.DefaultCellStyle.ForeColor = Color.Yellow;
row.DefaultCellStyle.BackColor = Color.Aquamarine;
}
}
}
}
덕분에 ...
이PS :이 코드를 잘 열과 행을 발견하지만
잠시 후에 함수를 호출하십시오, 어쩌면 FormLoad 또는 FormShown 이벤트 – TaW
을 형성 그것은 나던 일 :( – Berkin