title: Changing datagridview row color on condition vb.net
body: <p>I have loaded the data from database to datagridview and have two columns target value and volume where Item Unit >Item min value that volume cell should be in green color and Item min &lt; Item Unit then volume should be in red color. I tried it but I am not able to do it.</p>
  
  <p>Imports System.Data.SqlClient</p>
  
  <p>Public Class view_all</p>
  
  <pre><code>Dim con1 As SqlConnection
  
  Dim con As String  
  
  Dim da As SqlDataAdapter
  
  Dim ds As DataSet
  
  Private Sub view_all_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
      Dim obj As New config
  
      con1 = New SqlConnection
  
      con1 = obj.getcontion()
  
      con1.Open()
  
  
  
      da = New SqlDataAdapter("select * from item", con1)
  
      ds = New DataSet
  
      da.Fill(ds, "item")
  
      DataGridView1.DataSource = ds
  
      DataGridView1.DataMember = "item"
  
  
  
      DataGridView1.Columns(0).HeaderText = "Item Id"
      DataGridView1.Columns(1).HeaderText = "Item Name"
      DataGridView1.Columns(2).HeaderText = "Item Number"
      DataGridView1.Columns(3).HeaderText = "Item Propose"
      DataGridView1.Columns(4).HeaderText = "Item Unit "
      DataGridView1.Columns(5).HeaderText = "Item Max"
      DataGridView1.Columns(6).HeaderText = "Item min"
  
  End Sub
  </code></pre>