VB.NET - vb.net and sql flagging - Asked By mark acha on 01-Sep-13 07:35 AM

please help im newbie in programming im using vb.net and sql
 
i want to highlight with color cyan the value (1) for deletion i dont want to delete data instead i use to highlight it as way of deletion in vb.net when i stop and re run again the program the highlighted data was unhighlighted
 
this is my code:

  Private Sub dgvDoctorsList_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvDoctorsList.CellDoubleClick
 
  If MessageBox.Show("Are you sure want to delete this data ?", "CONFIRMATION", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = Windows.Forms.DialogResult.Yes Then
 
Dim objCmd As New SqlCommand()
Using con As New SqlConnection("server=ACHACOSOFAMILY;database=jjasgh;integrated security=true")
  objCmd.Connection = con
  con.Open()
 
  For Each objRow As DataGridViewRow In dgvDoctorsList.SelectedRows
    objCmd.CommandText = "Update tbl_Doctor SET Remarks=1 where License_no=@license"
 
    objCmd.Parameters.AddWithValue("@license", dgvDoctorsList.CurrentRow.Cells(0).Value)
    objCmd.ExecuteNonQuery()
    objRow.DefaultCellStyle.BackColor = Color.Cyan
 
  Next
       End Using
 
     con.Close()
    End sub
can anyone help me in this kind of problem thanks for consideration thanks in advance
Robbe Morris replied to mark acha on 02-Sep-13 11:48 AM
When you rerun the application, or even refresh the grid, you'll have to check the column value and set the appropriate cell background color.  Just setting once here:

objRow.DefaultCellStyle.BackColor = Color.Cyan

does not make this permanent.