How to export Gridview data to Excel using devexpress XtraGrid

To export Gridview data to Excel using devexpress XtraGrid have a look at the sample below.

Samples

C# Sample

VB.NET Sample

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

Please rate this snippet

How to get the selected row index in Devexpress Xtragrid Control using C# and VB.NET

To get the selected row index in Devexpress Xtragrid Control using C# and VB.NET you can use the snippet below.

Samples

Sample C#

Sample VB.NET

Compatibility: working .NET 2.0 working .NET 3.0 not tested .NET 3.5 not working .NET 4.0 not working .NET 4.5not working .NET 4.6

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

Please rate this snippet

How to Display an Image in Devexpress XtraGrid Control using C# and VB.NET

To Display an Image in Devexpress XtraGrid Control using C# and VB.NET see the example below.

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

Result

XtraGrid ColumnImages

XtraGrid ColumnImages


Please rate this snippet

How to get focusedrow cell value using Devexpress XtraGrid in C# and VB.NET

To get focusedrow cell value using Devexpress XtraGrid in C# and VB.NET you can use one of the following ways.

Samples

Sample C#

Sample VB.NET

 

Compatibility: working .NET 2.0 working .NET 3.0 not tested .NET 3.5 not working .NET 4.0 not working .NET 4.5not working .NET 4.6

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

 

Please rate this snippet

How to disable Devexpress Node Movement while Drag Drop in C# and VB.NET

To disable Devexpress Node Movement while Drag Drop in C# and VB.NET you can use the following snippet.

Sample C#

private void treeList1_DragOver(object sender, DragEventArgs e) 
{
	e.Effect = DragDropEffects.None;
}

private void treeList1_CalcNodeDragImageIndex(object sender, CalcNodeDragImageIndexEventArgs e) 
{
	e.ImageIndex = -1;
}

Sample VB.NET

Private Sub treeList1_DragOver(ByVal sender As Object, ByVal e As DragEventArgs)
	e.Effect = DragDropEffects.None
End Sub

Private Sub treeList1_CalcNodeDragImageIndex(ByVal sender As Object, ByVal e As CalcNodeDragImageIndexEventArgs)
	e.ImageIndex = -1
End Sub

Please rate this snippet

How to use Doubleclick in Devexpress Gridview in C# and VB.NET

Using doubleclick events in the Devexpress Gridview Control is a simple task.
There are 2 different ways of doing this. The variant you choose, depends on the Gridview’s gridView.OptionsBehavior.Editable property. If this property is set to false you have to use the DoubleClick event. If this property is set to true you have to use the ShownEditor and HiddenEditor event. I will also give an example on how to combine both methods, if you are using both (true and false) on the gridView.OptionsBehavior.Editable.

Samples

OptionsBehavior.Editable set to False

C# Sample

VB.NET Sample

OptionsBehavior.Editable set to True

When inplace editing is enabled, a click on a grid cell activates the inplace editor (rowedit).
All mouse events will be sent to the editor and cannot be handled by the GridView directly. The DoubleClick event handler is no longer being executed.

C# Sample

VB.NET Sample

OptionsBehavior.Editable set to True or False at Runtime

C# Sample

VB.NET Sample

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

Please rate this snippet

How to use Node Doubleclick in Devexpress Treelist in C# and VB.NET

How to use Node Doubleclick in Devexpress Treelist in C# and VB.NET you can use the following snippet.

Sample C#

private void treeList1_DoubleClick(object sender, EventArgs e) 
{
	var treeList = sender as TreeList;
	var hitInfo = treeList.CalcHitInfo(treeList.PointToClient(MousePosition));
	if(hitInfo.Node != null) 
	{
		//do something
	}
}

Sample VB.NET

Private Sub treeList1_DoubleClick(sender As Object, e As EventArgs)
	Dim treeList = TryCast(sender, TreeList)
	Dim hitInfo = treeList.CalcHitInfo(treeList.PointToClient(MousePosition))
			'do something
	If hitInfo.Node IsNot Nothing Then
	End If
End Sub

Please rate this snippet

How to get Devexpress Wizardpage by Name in C# and VB.NET

To get Devexpress Wizardpage by Name in C# and VB.NET you can use the following snippet.

Sample C#

public static WizardPage GetWizardPageByName(WizardControl wizard, string name)
{
	var controls = wizard.Controls.Find(name, false);
	if (controls.Length > 0 && controls[0] is WizardPage)
	{
		return controls[0] as WizardPage;
	}
	return null;
}

Sample VB.NET

Public Shared Function GetWizardPageByName(wizard As WizardControl, name As String) As WizardPage
	Dim controls = wizard.Controls.Find(name, False)
	If controls.Length > 0 AndAlso TypeOf controls(0) Is WizardPage Then
		Return TryCast(controls(0), WizardPage)
	End If
	Return Nothing
End Function

Please rate this snippet