| | |
| | | DataRow row = gridView1.GetDataRow(e.RowHandle); |
| | | if (row == null) |
| | | return; |
| | | //这是danger色 |
| | | bool columnExists = row.Table.Columns.Contains("isRed"); |
| | | if (columnExists == true) |
| | | { |
| | |
| | | if (_isRed == "1") |
| | | { |
| | | e.Appearance.ForeColor = Color.Tomato; |
| | | } |
| | | } |
| | | //这是success色 |
| | | columnExists = row.Table.Columns.Contains("isSuccess"); |
| | | if (columnExists == true) |
| | | { |
| | | string _isRed = row["isSuccess"].ToString(); |
| | | if (_isRed == "1") |
| | | { |
| | | e.Appearance.ForeColor = Color.FromArgb(128, 255, 128); |
| | | } |
| | | } |
| | | // 设置焦点行的背景色 |
| | |
| | | } |
| | | } |
| | | }; |
| | | |
| | | gridView1.RowStyle += (s, e) => |
| | | { |
| | | //默认选中行不变色 |
| | | gridView1.OptionsSelection.EnableAppearanceFocusedRow = false; |
| | | //默认选中单元格不变色 |
| | | gridView1.OptionsSelection.EnableAppearanceFocusedCell = false; |
| | | if (e.RowHandle >= 0) |
| | | { |
| | | DataRow row = gridView1.GetDataRow(e.RowHandle); |
| | | if (row == null) |
| | | return; |
| | | //这是danger色 |
| | | bool columnExists = row.Table.Columns.Contains("isRed"); |
| | | if (columnExists == true) |
| | | { |
| | | string _isRed = row["isRed"].ToString(); |
| | | if (_isRed == "1") |
| | | { |
| | | e.Appearance.ForeColor = Color.Tomato; |
| | | } |
| | | } |
| | | //这是success色 |
| | | columnExists = row.Table.Columns.Contains("isSuccess"); |
| | | if (columnExists == true) |
| | | { |
| | | string _isRed = row["isSuccess"].ToString(); |
| | | if (_isRed == "1") |
| | | { |
| | | e.Appearance.ForeColor = Color.FromArgb(128, 255, 128); |
| | | } |
| | | } |
| | | // 设置焦点行的背景色 |
| | | if (gridView1.GetRow(e.RowHandle) == gridView1.GetFocusedRow()) |
| | | { |
| | | e.Appearance.BackColor = Color.Azure; |
| | | e.Appearance.BackColor2 = Color.LightSkyBlue; |
| | | } |
| | | //else if (gridView1.IsRowHotTracked(e.RowHandle)) |
| | | //{ |
| | | // // 设置鼠标悬停行的背景色 |
| | | // e.Appearance.BackColor = Color.LightBlue; |
| | | // e.Appearance.BackColor2 = Color.LightBlue; |
| | | //} |
| | | } |
| | | }; |
| | | } |
| | | |
| | | #endregion |