[英]How To Display Image Into Devexpress GridView / Devexpress Card View From Mysql
Here I would like to ask, how to display the image data into DevExpress DevExpress gridview or CardView. 在这里,我想问一下如何将图像数据显示到DevExpress DevExpress gridview或CardView中。 For I will take a picture of data from mysql database that I keep with BLOB data type.
因为我将使用BLOB数据类型对mysql数据库中的数据进行拍照。
how or its code if using visual basic.? 如果使用Visual Basic怎么办?
for Code that I use: 对于我使用的代码:
Dim Query As String = "SELECT FTO.ALM_NIM as FOTO_ID, FTO.ALM_FOTO as FOTO FROM tbl_foto_alumni as FTO"
Using DA As New MySql.Data.MySqlClient.MySqlDataAdapter(Query, MyKonection)
Dim DTwisda As New DataTable
DA.Fill(DTwisda)
if Dtwisda.Rows.Count > 0 Then
GridControl.Datasource = DTwisda
MainView = CardView1
Dim RepItemImg As New Repository.RepositoryItemPictureEdit()
RepItemImg.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch
RepItemImg.BestFitWidth = 100
RepItemImg.CustomHeight = 150
With CardView1.Columns("FOTO")
.ColumnEdit = RepItemImg
End With
With CardView1
.OptionsBehavior.FieldAutoHeight = True
.MaximumCardRows = 2
.MaximumCardColumns = 6
End With
End If
End Using
To Screnshoot my program and the results of calling the data from the database, Please Check The Attachment. 要检查我的程序以及从数据库中调用数据的结果,请检查附件。 already I attach the following word file.
我已经附加了以下word文件。
ScreenShoot_Program ScreenShoot_Program
Please Help and Give The Solution. 请帮助并给出解决方案。
Regards, 问候,
Tafary 塔法里
Try This Code: 尝试以下代码:
Dim row As DataRow
Dim i As Integer
For Each row In myDt.Rows
Column = New DataColumn
With Column
.DataType = GetType(Bitmap)
' .DefaultValue = Base64ToImage(row("Photo"))
.Unique = False
.ColumnName = "EmpPhoto"
End With
If Not myDt.Columns.Contains("EmpPhoto") Then
myDt.Columns.Add(Column)
End If
myDt.Rows(i)("EmpPhoto") = Base64ToImage(row("Photo"))
i += 1
myDt.AcceptChanges()
Next
i = 0
'myDt.Rows.Add(Column.DefaultValue)
Public Function Base64ToImage(base64String As String) As Image
Try
' Convert Base64 String to byte[]
Dim imageBytes As Byte() = Convert.FromBase64String(base64String)
Dim ms As New MemoryStream(imageBytes, 0, imageBytes.Length)
' Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length)
Dim image1 As Image = Image.FromStream(ms, True)
Return image1
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.