Click here to Skip to main content
15,789,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I have datagridview which populates from sqlce table and displays. I am now planning to display country flags in the country cells that corresponds the country in another cell. The flags are JPG type and stored in imagelist1. Would anyone please help me on how to achieve the result?

What I have tried:

The code is here:
Private Sub frmemplist_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    DGVEmp.DataSource = getemployees()
    'Set DGV Column to certain Width
    NumHold.Text = DGVEmp.RowCount

    DGVEmp.Columns.Item("EmpID").Width = 55
    DGVEmp.Columns.Item("EmployeeName").Width = 200
    DGVEmp.Columns.Item("Designation").Width = 180
    DGVEmp.Columns.Item("Gender").Width = 120
    DGVEmp.Columns.Item("SkillLevel").Width = 140
    DGVEmp.Columns.Item("Department").Width = 60
    DGVEmp.Columns.Item("Site").Width = 125
    DGVEmp.Columns.Item("Status").Width = 125
    DGVEmp.Columns.Item("Nationality").Width = 115
This is here i want to display country flag
    DGVEmp.Columns.Item("ImagePath").Width = 100
End Sub
Private Function getemployees() As DataTable
    Dim dttable As New DataTable
    Dim ConnectionString As String = "Data Source=C:\Users\User\Documents\Visual Studio 2012\Projects\HSEDB-Oman\HSEDB-Oman\HSEDBOman.sdf"
    Using con As New SqlCeConnection(ConnectionString)
        Using cmd As New SqlCeCommand("SELECT EmpID, EmployeeName, Designation, Gender, SkillLevel, Department, Site," _
                                      & "Status, Nationality, ImagePath FROM tblemployees Where EmpID IS NOT Null", con)
            Dim reader As SqlCeDataReader = cmd.ExecuteReader()
        End Using
    End Using
    Return dttable
End Function

Please share me some help because i am unable to get this done!

Thanks & regards,
Updated 10-May-18 3:43am

1 solution

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900