如何在imagelist中的datagridview单元格中显示国家/地区标志图标? [英] How do I display a country flag icon in datagridview cell from imagelist?

查看:132
本文介绍了如何在imagelist中的datagridview单元格中显示国家/地区标志图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我有来自sqlce表并显示的datagridview。我现在计划在国家单元格中显示与另一个单元格中的国家/地区对应的国家/地区标志。标志是JPG类型并存储在imagelist1中。有人可以帮我解决如何达到这个结果吗?



我尝试过的事情:



代码在这里:

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)
            con.Open()
            Dim reader As SqlCeDataReader = cmd.ExecuteReader()
            dttable.Load(reader)
            con.Close()
        End Using
    End Using
    Return dttable
End Function



请分享一些帮助,因为我无法完成这项工作!



谢谢&问候,


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

Thanks & regards,

推荐答案

参见 DataGridViewImageColumn [ ^ ]。


这篇关于如何在imagelist中的datagridview单元格中显示国家/地区标志图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆