Results 1 to 2 of 2

Thread: Add column containing image to DGV

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    Add column containing image to DGV

    Hello,

    I am generating the contents for my DGV by using the following code:

    Code:
     Dim strMEDEWERKER As String = "IIf(isnull(tblMEDEWERKER.Voorvoegsel),tblMEDEWERKER.Voornaam & ' ' & tblMEDEWERKER.Achternaam,tblMEDEWERKER.Voornaam & ' ' &tblMEDEWERKER.Voorvoegsel & ' ' & tblMEDEWERKER.Achternaam)"
        Dim strComm As String = String.Format("SELECT tblMEDEWERKER.Medewerker_ID, " & _
                                              "{0} AS VolledigeNaam, " & _
                                              "tblMEDEWERKER.Postcode, " & _
                                              "tblMEDEWERKER.Plaats, " & _
                                              "tblMEDEWERKER.Achternaam, " & _
                                              "tblMEDEWERKER.Voornaam, " & _
                                              "tblMEDEWERKER.Voorvoegsel " & _
                                              "FROM tblMEDEWERKER " & _
                                              "WHERE {1} " & _
                                              "AND {2} " & _
                                              "AND {3} " & _
                                              "AND {4} ", _
                                              strMEDEWERKER, _
                                              strZoekMedewerker_ID, _
                                              strZoekPostcode, _
                                              strZoekPlaats, _
                                              strZoekVolledigeNaam) 'IIf(txtZoekPlaats.Text = "", "is null AND tblMEDEWERKER.Plaats <> NULL", "like '%" & txtZoekPlaats.Text & "%'"), _
    
        'Debug.WriteLine(strComm) 'Copy the string from the Debug window
    
        Dim adapter As New OleDbDataAdapter(strComm, connection)
    
        Dim table As New DataTable
        adapter.Fill(table)
    
        With dgvMedewerker
          .DataSource = table
          .Visible = True
        End With
    I would like to add a column containing an image to the end of the DGV.
    I searched the forum but didn't find anything to fit my needs.

    Could you please give me a push in the right direction?

    Thanks in advance

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add column containing image to DGV

    You simply add a DataGridViewImageColumn to the grid. You can do it in the designer or in code. If you do it in the designer then you will need to change the DisplayIndex after binding the data.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width