2 Replies - 8036 Views - Last Post: 03 June 2013 - 02:59 AM Rate Topic: -----

#1 little_prince41  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 10-August 07

Question: Display image in cell of datagridview

Posted 31 May 2013 - 02:49 AM

Hi.
I need to load database from access file to datagridview then check condition in cell befor change string data in cell to image with conditon.
----------------------------------------------------------------
ex.
string ="1" will load image "1.png"
string ="1" will load image "2.png"
---------------------------------------------------------------
but my database cell type is string when load image in cell will show string "System.Drawing.Bitmap" how to solve this a problem.
i'm so sorry, my english is not well.

Thanks.

This post has been edited by little_prince41: 31 May 2013 - 02:50 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Question: Display image in cell of datagridview

#2 Linesofcode  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 62
  • Joined: 23-May 13

Re: Question: Display image in cell of datagridview

Posted 31 May 2013 - 03:04 AM

Maybe you should create the cells dynamically. So, when you compare, you would be able to create a specific cell for a specific row.
Was This Post Helpful? 0
  • +
  • -

#3 little_prince41  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 10-August 07

Re: Question: Display image in cell of datagridview

Posted 03 June 2013 - 02:59 AM

Hi

I can load image to cell of datagridview but I need to input string into cell(Edit value) and save back to database.
How to do!

Here my code.
Imports System.Text
Imports System.ComponentModel
Imports Microsoft.VisualBasic
Imports DevComponents.DotNetBar
Imports DevComponents.DotNetBar.Controls
Imports DevComponents.DotNetBar.Rendering
Public Class Form1
    Public connecting As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|datadirectory|\Test.accdb;persist security info=false"
    Public conn As New OleDbConnection
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conn.ConnectionString = connecting
        If conn.State = ConnectionState.Closed Then
            conn.Open()
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim SqlQuery As String = "SELECT * FROM Account"
        Dim SqlCommend As New OleDbCommand
        Dim SqlAdapter As New OleDbDataAdapter
        Dim TABLE As New DataTable
        With SqlCommend
            .CommandText = SqlQuery
            .Connection = conn
        End With
        With SqlAdapter
            .SelectCommand = SqlCommend
            .Fill(TABLE)
        End With
        Me.DataGridViewX1.Rows.Clear()
        For i As Integer = 0 To TABLE.Rows.Count - 1
            With Me.DataGridViewX1
                .Rows.Add(TABLE.Rows(i)("ID"), TABLE.Rows(i)("Fullname"), TABLE.Rows(i)("image"))
            End With
        Next
        If CStr(Me.DataGridViewX1.Rows(0).Cells(2).Value) = "1" Then
            'Dim imgNormal As Image
            'imgNormal = Me.ImageList1.Images(0)
            DataGridViewX1.Rows(0).Cells(2).Value = ImageList1.Images(0)
                    End If

    End Sub


This post has been edited by little_prince41: 03 June 2013 - 03:01 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1