Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Function SqlPopulateMembers()
  2.         Dim result As String = ""
  3.         Dim myAdapter As New MySqlDataAdapter
  4.         Dim myData As New DataTable
  5.  
  6.         Try
  7.             Dim cmd As New MySqlCommand("SELECT * FROM Users", connection)
  8.             SqlConnect()
  9.  
  10.             myAdapter.SelectCommand = cmd
  11.             myAdapter.Fill(myData)
  12.  
  13.             With frmMembers
  14.                 .dgView.DataSource = myData
  15.                 .dgView.Columns(0).Visible = False
  16.                 .dgView.Columns(2).Visible = False
  17.                 .dgView.Columns(4).Visible = False
  18.                 .dgView.Columns(5).Visible = False
  19.                 .dgView.Columns(6).Visible = False
  20.             End With
  21.  
  22.             connection.Close()
  23.         Catch ex As Exception
  24.             MsgBox(ex.Message)
  25.         End Try
  26.  
  27.         Return result
  28.     End Function
  29.  
  30.  
  31. Private Sub dgView_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles dgView.CellFormatting
  32.         If e.ColumnIndex = 3 Then
  33.             Dim row As DataGridViewRow = dgView.Rows(e.RowIndex)
  34.             Dim cell As DataGridViewCell = row.Cells(3)
  35.  
  36.             If CInt(cell.Value) = 0 Then
  37.                 Dim col As DataGridViewImageColumn = DirectCast(dgView.Columns(3), DataGridViewImageColumn)
  38.                 col.Image = dgImages.Images(0)
  39.             ElseIf CInt(cell.Value) = 1 Then
  40.                 Dim col As DataGridViewImageColumn = DirectCast(dgView.Columns(3), DataGridViewImageColumn)
  41.                 col.Image = dgImages.Images(1)
  42.             End If
  43.         End If
  44.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement