private void dgv_CellFormatting(object sender,DataGridViewCellFormattingEventArgs e)
{
try
{
DataGridView dgv = (sender as DataGridView);
if (dgv.Columns["dgvIsSelf"].Index == e.ColumnIndex)
{
if (Convert.ToBoolean(e.Value) == true) //是自費時,該列的顏色為黃色
{
dgv.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Yellow;
}
else
{
dgv.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White;
}
}
}
catch (Exception ex)
{
ex.ToString();
}
}
沒有留言:
張貼留言