We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to assign image from file into ggc record field cell?

Hello Haneef,

I have item table and need to put different picture according to respective item name by double click the cell, then save it into dataset.

Private Sub ggc_TableControlCellDoubleClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs) Handles ggc.TableControlCellDoubleClick
If e.TableControl.TableDescriptor.Name = "Item" Then
Dim column As GridColumnDescriptor = e.TableControl.Table.GetColumnDescriptorAt(e.Inner.RowIndex, e.Inner.ColIndex)
If column.Name = "Photo" Then
Dim OpenFileDialog As OpenFileDialog = New OpenFileDialog()
OpenFileDialog.Title = "Load Photo"
OpenFileDialog.Filter = "Image File (*.jpg;*.gif;*.bmp)|*.jpg;*.gif;*.bmp"

If OpenFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso OpenFileDialog.CheckPathExists Then

Dim fs As New System.IO.FileStream(OpenFileDialog.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim bm As New Bitmap(fs)
...

end sub

ggc.TableDescriptor.Columns("Photo").Appearance.AnyRecordFieldCell.CellType = "PictureBox"

How to perfectly code it in VB?

Thank you for your help!

Best Regards,
Harry


2 Replies

AD Administrator Syncfusion Team March 26, 2008 06:43 PM UTC

Hi Harry,

Here is a code snippet in VB.Net.

Private Sub gridGroupingControl1_TableControlCellDoubleClick(ByVal sender As Object, ByVal e As GridTableControlCellClickEventArgs)
'if (e.TableControl.TableDescriptor.Name == "Item")
Dim column As GridColumnDescriptor = e.TableControl.Table.GetColumnDescriptorAt(e.Inner.RowIndex, e.Inner.ColIndex)
If column.Name = "Photo" Then
Dim OpenFileDialog As OpenFileDialog = New OpenFileDialog()
OpenFileDialog.Title = "Load Photo"
OpenFileDialog.Filter = "Image File (*.jpg;*.gif;*.bmp;*.jpeg;*.png)|*.jpg;*.gif;*.bmp;*.jpeg;*.png"
If OpenFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK AndAlso OpenFileDialog.CheckPathExists Then
Dim fs As System.IO.FileStream = New System.IO.FileStream(OpenFileDialog.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim bm As Bitmap = New Bitmap(fs)
Dim Rec As Syncfusion.Grouping.Record = Me.gridGroupingControl1.Table.CurrentRecord
Rec.SetValue("Photo", bm)
Me.gridGroupingControl1.Refresh()
End If
End If
End Sub

Please refer to the attached sample for implementation and let me know this helps.

http://websamples.syncfusion.com/Samples/Grid.Windows/F72133/main.htm



Best regards,
Johnson




AD Administrator Syncfusion Team May 8, 2008 02:50 AM UTC

Hello Johnson,

Thank you for your assist.


Loader.
Live Chat Icon For mobile
Up arrow icon