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 load a custom mouse cursor in C# and VB.NET

To load a custom mouse cursor in C# and VB.NET you can use the follwing snippet.

Sample C#

using System.Runtime.InteropServices;

[DllImport("user32.dll", EntryPoint = "LoadCursorFromFileW", CharSet = CharSet.Unicode)]
public static extern IntPtr LoadCursorFromFile(String str);

public void main()
{
	IntPtr cursorHandle = LoadCursorFromFile(file);
	this.Cursor = new Cursor(cursorHandle);
}

Sample VB.NET

Imports System.Runtime.InteropServices

Public Declare Function LoadCursorFromFile Lib "user32.dll" Alias "LoadCursorFromFileW" (ByVal str As String) As IntPtr

Public Sub main()
	Dim cursorHandle As IntPtr = LoadCursorFromFile(file)
	Me.Cursor = New Cursor(cursorHandle)
End Sub

Please rate this snippet