private delegate void SetDataGridDataRowColor(DataGridView dv, int row, Color c);
private void SetdataGridRowColor(DataGridView dv, int row, Color c)
{
if (dv.InvokeRequired)
{
dv.Invoke(new SetDataGridDataRowColor(SetdataGridRowColor), dv, row, c);
}
else
{
dv.Rows[row].DefaultCellStyle.BackColor = c;
}
}
private delegate void SetDataGridDataRow(DataGridView dv, int row, string strLine);
private void SetdataGridRow(DataGridView dv, int row, string strLine)
{
if (dv.InvokeRequired)
{
dv.Invoke(new SetDataGridDataRow(SetdataGridRow), dv, row, strLine);
}
else
{
int status = 0;
bool superAnonymous = false;
int id = int.Parse(dv.Rows[row].Cells["P_ID"].Value.ToString());
if (strLine.Contains(@"验证失败"))
{
dv.Rows[row].Cells["Status"].Value = 0;
status = 0;
dv.Rows[row].Cells["SuperAnonymous"].Value = false;
dv.Rows[row].DefaultCellStyle.ForeColor = Color.DarkGray;
}
else
{
dv.Rows[row].Cells["Status"].Value = 1;
status = 1;
dv.Rows[row].Cells["SuperAnonymous"].Value = false;
dv.Rows[row].DefaultCellStyle.ForeColor = Color.DarkOrange;
}
new DBOperator().ModifyProxy(id, status, superAnonymous);
SetdataGridRowColor(ProxydataGridView, row, ProxydataGridView.DefaultCellStyle.BackColor);
}
}
private delegate void SetDataGridDataRowSource(DataGridView dv, DataTable table);
private void SetdataGridRowSource(DataGridView dv, DataTable table)
{
if (dv.InvokeRequired)
{
dv.Invoke(new SetDataGridDataRowSource(SetdataGridRowSource), dv, table);
}
else
{
dv.DataSource = table;
}
}
动态添加DataGridView Row Color
最新推荐文章于 2023-11-23 08:06:29 发布