0% found this document useful (0 votes)
328 views

How To Display An Image in Devexpress XtraGrid Control Using C# and

This document provides a code sample for displaying an image in a DevExpress XtraGrid control using C# and VB.NET. It shows how to: 1) Create a DataTable with columns for ID, URL, and Image. 2) Populate the DataTable with sample data including an Image. 3) Set the DataTable as the DataSource for a gridControl and set the Image column to use a RepositoryItemPictureEdit to display the image.

Uploaded by

MadheSatyawan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
328 views

How To Display An Image in Devexpress XtraGrid Control Using C# and

This document provides a code sample for displaying an image in a DevExpress XtraGrid control using C# and VB.NET. It shows how to: 1) Create a DataTable with columns for ID, URL, and Image. 2) Populate the DataTable with sample data including an Image. 3) Set the DataTable as the DataSource for a gridControl and set the Image column to use a RepositoryItemPictureEdit to display the image.

Uploaded by

MadheSatyawan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

How to Display an Image in

Devexpress XtraGrid Control


using C# and VB.NET
Sample C#

#region
 
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using WindowsFormsApplication77.Properties;
using DevExpress.XtraEditors.Repository;
 
#endregion
 
namespace de.fesslersoft.XtraGridImageTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            gridControl1.DataSource = CreateTable(3);
            gridView1.Columns["Image"].ColumnEdit = new
RepositoryItemPictureEdit();
        }
 
        private DataTable CreateTable(int rowCount)
        {
            var image = Resources.Image1;
            var tbl = new DataTable();
            tbl.Columns.Add("ID", typeof (int));
            tbl.Columns.Add("URL", typeof (string));
            tbl.Columns.Add("Image", typeof (Image));
            for (var i = 0; i < rowCount; i++)
            {
                tbl.Rows.Add(new object[]
{i, "http://codesnippets.fesslersoft.de", image});
            }
            return tbl;
        }
    }
}
Sample VB.NET
#Region ""
 
Imports System.Data
Imports System.Drawing
Imports System.Windows.Forms
Imports WindowsFormsApplication77.Properties
Imports DevExpress.XtraEditors.Repository
 
#End Region
 
Namespace de.fesslersoft.XtraGridImageTest
    Public Partial Class Form1
        Inherits Form
        Public Sub New()
            InitializeComponent()
            gridControl1.DataSource = CreateTable(3)
            gridView1.Columns("Image").ColumnEdit = New
RepositoryItemPictureEdit()
        End Sub
 
        Private Function CreateTable(rowCount As Integer) As DataTable
            Dim image = Resources.Image1
            Dim tbl = New DataTable()
            tbl.Columns.Add("ID", GetType(Integer))
            tbl.Columns.Add("URL", GetType(String))
            tbl.Columns.Add("Image", GetType(Image))
            For i As var = 0 To rowCount - 1
                tbl.Rows.Add(New Object()
{i, "http://codesnippets.fesslersoft.de", image})
            Next
            Return tbl
        End Function
    End Class
End Namespace

You might also like