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 show and select a file in explorer using C# and VB.NET

To show and select a file in explorer using C# and VB.NET you can use the following snippet.

Sample C#

private static void ShowFileInExplorer(string filePath)
{
	try
	{
		var winDir = Environment.GetEnvironmentVariable("windir");
		if (winDir != null)
		{
			var explorerPath = Path.Combine(winDir, @"explorer.exe");
			var arguments = String.Format("/select, {0}{1}{0}", (char)34, filePath);
			Process.Start(explorerPath, arguments);
		}
	}
	catch (Exception ex)
	{
		//handle the exception your way!
	}
}

Sample VB.NET

Private Shared Sub ShowFileInExplorer(filePath As String)
	Try
		Dim winDir = Environment.GetEnvironmentVariable("windir")
		If winDir IsNot Nothing Then
			Dim explorerPath = Path.Combine(winDir, "explorer.exe")
			Dim arguments = [String].Format("/select, {0}{1}{0}", Char(34), filePath)
			Process.Start(explorerPath, arguments)
		End If
	Catch ex As Exception
	        'handle the exception your way!
        End Try
End Sub

Please rate this snippet

How to show and select a file in explorer using VBA

To show and select a file in explorer using VBA you can use the following snippet.
This snippet should also work in VB6.

Sample VBA

Dim path As String
Dim explorerPath As String
Dim cmd As String

explorerPath = Environ$("WINDIR") + "\Explorer.exe "
path = "C:\Users\Codesnippets\Desktop\test\Test.xml"
cmd = explorerPath + " /select , " + Chr(34) + path + Chr(34)
Call Shell(cmd, vbNormalFocus)

Please rate this snippet

How to get the text selection in Javascript

To get the text selection in Javascript you can use the following snippet.

Sample Javascript

function GetTextSelection() {
	return (!!document.getSelection) ? document.getSelection() :
	       (!!window.getSelection)   ? window.getSelection() :
	       document.selection.createRange().text;
}

Please rate this snippet