0
필드를 기반으로 DataTable 행의 색상을 변경하는 방법 (예 : 일부 필드가 비어있는 경우 행의 색상을 변경하고 싶습니다) Windows Forms C#에서?Winforms datatable (datagridview가 아닌) 필드를 기반으로 한 행의 색상을 변경하십시오.
Datatable에 대해 뭔가가 있습니까?
필드를 기반으로 DataTable 행의 색상을 변경하는 방법 (예 : 일부 필드가 비어있는 경우 행의 색상을 변경하고 싶습니다) Windows Forms C#에서?Winforms datatable (datagridview가 아닌) 필드를 기반으로 한 행의 색상을 변경하십시오.
Datatable에 대해 뭔가가 있습니까?
:
private void dataGridView1_CellFormatting(object sender,
System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
{
// check against your column name here
if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("Balance"))
{
// we are now in the correct column
String stringValue = e.Value as string;
DataGridViewCell cell = dataGridView1[e.ColumnIndex, e.RowIndex];
switch (stringValue)
{
case "high":
cell.BackColor = Color.Red;
break;
case "medium":
...
break;
}
}
}
도 그런 일이 데이터 테이블 UI 컨트롤로이 있습니까? – sprocket12
아, 죄송합니다, DataTable은 DataGridView의 소스입니다 –
감사합니다, 감사합니다 dataGridView1.Rows [Rowindex] .DefaultCellStyle.BackColor = Color.LightBlue; –