I'm creating a daily planner, in which tasks are entered into a datagridview
as follows:
Tasks also have a priority set by the user, as seen above.
I'm trying to achieve the following, however, I'm not sure how to code this:
If the priority is set to "High" then the cell in which the priority is displayed will change its color to red.
If the priority is set to "Medium" then the cell in which the priority is displayed will change its color to yellow.
If the priority is set to "Low" then the cell in which the priority is displayed will change its color to green.
How would I go about achieving such a feature?
Try this:
For each row As DataGridViewRow In Datagridview1
If row.Cells(3).Text.Trim = "High" Then
row.Cells(3).Style.Backcolor = Color.Red
Else If row.Cells(3).Text.Trim = "Low" Then
...
Else If row.Cells(3).Text.Trim = "Medium" Then
...
End If
Next
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.