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

Left, Right, Mid methods for C#

This snippet let’s you use the Left, Right, Mid methods known from VisualBasic in C# without referencing Microsoft.VisualBasic Namespace.

public static string Left(string input, int index)
{
	return input.Substring(0, index);
}
public static string Right(string input, int index)
{
	return input.Substring(input.Length - index, index);
}

public static string Mid(string input, int startingIndex, int endingIndex)
{
	return input.Substring(startingIndex, endingIndex);
}

public static string Mid(string input, int startingIndex)
{
	return input.Substring(startingIndex);
}

Please rate this snippet

Mid, Left, Right Extension Methods for C# and VB.NET

Here are three Extension Methods which let you use the Left, Mid and Right Methods from VB6 in C# and VB.NET. The Extension Methods simply wrap the on-board .NET Framework Method Substring. These Extension Methods are now part of the Fesslersoft.Extensions.

Samples

C# Sample

VB.NET Sample

Compatibility (as Extension method):
working .NET 2.0 working .NET 3.0 not tested .NET 3.5 not working .NET 4.0 not working .NET 4.5
Compatibility (Non-Extension method):
working .NET 2.0 working .NET 3.0 not tested .NET 3.5 not working .NET 4.0 not working .NET 4.5

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