How to select a item on rightclick using devexpress ListboxControl

To select a item on rightclick using devexpress ListboxControl you need to use the MouseDown Event.
See the samples below.

Sample C#

private void listBoxControl1_MouseDown(object sender, MouseEventArgs e)
{
	listBoxControl1.SelectedIndex = listBoxControl1.IndexFromPoint(new Point(e.X, e.Y));
}

Sample VB.NET

Private Sub listBoxControl1_MouseDown(sender As Object, e As MouseEventArgs)
	listBoxControl1.SelectedIndex = listBoxControl1.IndexFromPoint(New Point(e.X, e.Y))
End Sub

Please rate this snippet

How to scroll to the end of a Textbox in C# and VB.NET

To scroll to the end of a Textbox in C# and VB.NET you can use the following snippet.

Sample C# / VB.NET

listBox1.SelectedIndex = listBox1.Items.Count - 1;
listBox1.SelectedIndex = -1;

Please rate this snippet

How to make a multicolumn listbox in VBA

To make a multicolumn listbox in VBA you can use the following snippet.
This snippet should also work in VB6.

Sample VBA

Option Compare Database
Option Explicit

Private Sub Form_Load()
    FillListbox
End Sub

Public Sub FillListbox()
Dim i As Integer

Listbox1.Clear
Listbox1.ColumnCount = 4

For i = 0 To 9
    Listbox1.AddItem "Row" + CStr(i) + "; Column1"
    Listbox1.List(i, 1) = "Row" + CStr(i) + "; Column2"
    Listbox1.List(i, 2) = "Row" + CStr(i) + "; Column3"
    Listbox1.List(i, 3) = "Row" + CStr(i) + "; Column4"
Next
End Sub

Please rate this snippet

AddToEnd listbox extension for C# and VB.NET

The simple but usefull AddToEnd listbox extension for C# and VB.NET.

Sample C#

public static void AddToEnd(this ListBox listbox, object data)
{
	listbox.Items.Add(data);
	listbox.TopIndex = listbox.Items.Count - 1;
	listbox.ClearSelected();
}

Sample VB.NET

<System.Runtime.CompilerServices.Extension> _
Public Shared Sub AddToEnd(listbox As ListBox, data As Object)
	listbox.Items.Add(data)
	listbox.TopIndex = listbox.Items.Count - 1
	listbox.ClearSelected()
End Sub

Please rate this snippet