title: Show different image in dataGridview from sql server
body: <p>I have a table in sql server that have column have images, and I retrieve the image by adding image column in <code>Gridview</code> if the user click on image column, the application go to database and check if that row have data in image column will show the picture in new form, every thing is perfect 
  and this is the code :</p>
  
  <p>this id how I fill the <code>Gridview</code>:</p>
  
  <pre><code>Sub FillGridd()
      Dim cbb As New DataGridViewComboBoxColumn() With {.HeaderText = "currency"}
      cbb.Items.Add("shekel")
      cbb.Items.Add("dinar")
      cbb.Items.Add("dollar")
      cbb.Items.Add("euro")
      cbb.Items.Add("yuan")
      cbb.FlatStyle = FlatStyle.Flat
      'Delete Button
      Dim btnDelete As New DataGridViewButtonColumn()
      btnDelete.FlatStyle = FlatStyle.Flat
      'Image Button
      Dim btnImage As New DataGridViewButtonColumn()
      btnDelete.FlatStyle = FlatStyle.Popup
  
      Dim column = New CalendarColumn() With {.HeaderText = "Date"}
      column.DefaultCellStyle.Format = "dd/MM/yyyy h:mm:ss tt"
      column.DataPropertyName = "Date"
  
      MetroGrid2.Columns.Insert(0, btnDelete)
      MetroGrid2.Columns.Add("", "المبلغ المرسل")
      MetroGrid2.Columns.Add(cbb)
      MetroGrid2.Columns.Add("", "Commission")
      MetroGrid2.Columns.Add("", "receiver name")
      MetroGrid2.Columns.Add("", "receiver phone")
      MetroGrid2.Columns.Add("", "Recipient country")
      MetroGrid2.Columns.Add("", "sender's name")
      MetroGrid2.Columns.Add("", "sender's phone")
      MetroGrid2.Columns.Add("", "the recipient company")
      'MetroGrid2.Columns.Add("", "Date")
      MetroGrid2.Columns.Add(column)
      MetroGrid2.Columns.Add(btnImage)
      MetroGrid2.Columns.Add("", "Notes")
      MetroGrid2.Columns.Add("", "ID")
      MetroGrid2.Columns(13).Visible = False
  
  
      Const sqlstring As String = "SELECT * FROM money_sent WHERE date &gt;= DATEADD(DAY, -30, GETDATE()) ORDER BY Date DESC"
  
      If SQL.conn.State = ConnectionState.Open Then
          SQL.conn.Close()
      End If
      SQL.conn.Open()
      Dim adt As New SqlDataAdapter(sqlstring, SQL.conn)
      Dim dt As New DataTable
      adt.Fill(dt)
      Dim i As Integer
      For i = 0 To dt.Rows.Count - 1
          MetroGrid2.Rows.Add()
          MetroGrid2.Rows(i).Cells(1).Value = dt.Rows(i).ItemArray(1)
          Dim cell As DataGridViewComboBoxCell = DirectCast(MetroGrid2.Rows(i).Cells(2), DataGridViewComboBoxCell)
          cell.Value = dt.Rows(i).ItemArray(2)
          MetroGrid2.Rows(i).Cells(3).Value = dt.Rows(i).ItemArray(3)
          MetroGrid2.Rows(i).Cells(4).Value = dt.Rows(i).ItemArray(4)
          'DataGridView1.Rows(i).Cells(4).Value = "DELETE"
          MetroGrid2.Rows(i).Cells(5).Value = dt.Rows(i).ItemArray(5)
          MetroGrid2.Rows(i).Cells(6).Value = dt.Rows(i).ItemArray(6)
          MetroGrid2.Rows(i).Cells(7).Value = dt.Rows(i).ItemArray(7)
          MetroGrid2.Rows(i).Cells(8).Value = dt.Rows(i).ItemArray(8)
          MetroGrid2.Rows(i).Cells(9).Value = dt.Rows(i).ItemArray(9)
          MetroGrid2.Rows(i).Cells(10).Value = dt.Rows(i).ItemArray(10)
          MetroGrid2.Rows(i).Cells(12).Value = dt.Rows(i).ItemArray(12)
          MetroGrid2.Rows(i).Cells(13).Value = dt.Rows(i).ItemArray(0)
      Next
      SQL.conn.Close()
  
      'MetroGrid2.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal
      MetroGrid2.CellBorderStyle = DataGridViewCellBorderStyle.Single
      Me.MetroGrid2.GridColor = Color.WhiteSmoke
  End Sub
  </code></pre>
  
  <p>this is how i add clickable image in <code>Gridview</code>:</p>
  
  <pre><code>     Private Sub MetroGrid2_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles MetroGrid2.CellContentClick
      id = MetroGrid2.SelectedRows(0).Cells(13).Value
      If e.ColumnIndex = 11 Then
              Dim dr As SqlDataReader
              Dim cmd As SqlCommand
              Dim stream As New MemoryStream()
              Dim query As String
              query = "select * from money_sent where id='" &amp; id &amp; "'"
  
              If SQL.conn.State = ConnectionState.Open Then
                  SQL.conn.Close()
              End If
              SQL.conn.Open()
              cmd = New SqlCommand(query, SQL.conn)
              'dr = Cmd.ExecuteReader
              dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
              While dr.Read
                  If dr("idpicture").ToString() &lt;&gt; "" Then
                      Dim image As [Byte]() = DirectCast(dr("idpicture"), [Byte]())
                      stream.Write(image, 0, image.Length)
                      Dim bitmap As New Bitmap(stream)
                      'Form3.PictureBox1.Image = bitmap
                      Dim frm As New Form3
                      frm.PictureBox1.Image = bitmap
                      frm.id = id
                      frm.sname = MetroGrid2.SelectedRows(0).Cells(7).Value
                      frm.ShowDialog()
                  Else
                      noimage = "no"
                  End If
              End While
              SQL.conn.Close()
  
              If noimage = "no" Then
                  If MessageBox.Show("there is no image for this record do you want add image ?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                      UpdateImage()
                  End If
              End If
          End If
  End Sub
  </code></pre>
  
  <p>This is All the code, now what i want is how to show different image in the <code>Gridview</code> Image column for the row that have picture in database, so the user can distinguish the row that have picture from the one that no picture in it.</p>
  
  <p>This is How the Image column in the <code>Gridview</code>:
  <a href="https://i.stack.imgur.com/seU0Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/seU0Y.png" alt="enter image description here"></a></p>