Dear Agarwal,
I really appreciate your help, unfortunitly i still cannot see the Pictures, Folling is the code including your suggestions:
Public Sub DGBLoad()
Try
Windows.Forms.Cursor.Current = Windows.Forms.Cursors.WaitCursor
DGB.DataSource = Nothing
DGB.Rows.RemoveRange(1, DGB.Rows.Count - 1)
'ODBC
SqlStr = "SELECT status.StateIcon, Charge.ChargenNr, status.statuseng, status.status_id, Charge.AuftragNr FROM Charge LEFT JOIN status ON Charge.Status = status.status_id " & _
"WHERE Charge.AuftragNr = '" & GetString(Glb_POno) & "' ORDER BY Charge.ChargenNr"
Dim Odbcda As New Odbc.OdbcDataAdapter(SqlStr, connectionString)
odbcDataSet = New DataSet
Odbcda.Fill(odbcDataSet, "DGBList")
Dim dt As DataTable = odbcDataSet.Tables("DGBList")
DGB.DataSource = dt
With DGB
.Cols(0).Visible = False
.Cols(1).Caption = "Picture"
.Cols(1).WidthDisplay = 200
.Cols(2).Caption = "Bundle no"
.Cols(2).Width = 200
.Cols(3).Caption = "State"
.Cols(3).Width = 200
.Cols(4).Width = 0
.Cols(5).Width = 0
End With
DGB.DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw
AddHandler DGB.OwnerDrawCell, AddressOf DGB_OwnerDrawCell
DGB.Rows.DefaultSize = 100
DGB.Rows(1).Selected = False
Windows.Forms.Cursor.Current = Windows.Forms.Cursors.Default
Catch ex As Exception
MsgBox("Error 'DGBLoad' : " & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
Finally
Windows.Forms.Cursor.Current = Windows.Forms.Cursors.Default
End Try
End Sub
Sub DGB_OwnerDrawCell(sender As Object, e As C1.Win.C1FlexGrid.OwnerDrawCellEventArgs)
Try
If (e.Col).Equals(1) AndAlso e.Row > 0 Then
e.Image = GetImageFromByteArray(TryCast(DGB(e.Row, e.Col), Byte))
e.Style.ImageAlign = C1.Win.C1FlexGrid.ImageAlignEnum.Stretch
e.Style.Display = C1.Win.C1FlexGrid.DisplayEnum.ImageOnly
End If
Catch ex As Exception
MsgBox("Error 'DGB_OwnerDrawCell' : " & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
End Try
End Sub
Private Function GetImageFromByteArray(picData As Byte()) As Image
Try
If (picData) Is Nothing Then
Return Nothing
End If
'' is this is an embedded object
Dim bmData As Integer = If((picData(0) = 21 AndAlso picData(1) = 28), 78, 0)
'' load the picture
Dim img As Image = Nothing
Try
Dim ms As New System.IO.MemoryStream(picData, bmData, picData.Length - bmData)
img = Image.FromStream(ms)
Catch
End Try
'' return what we got
Return img
Catch ex As Exception
MsgBox("Error 'GetImageFromByteArray' : " & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
End Try
End Function
Best regards
Said Nai