How to create an alert dialog in Android

To create an alert dialog in Android you can use the following snippet.

Sample Java

new AlertDialog.Builder(this)
    .setTitle("Delete items")
    .setMessage("Are you sure you want to delete this items?")
    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) { 
            // YES
        }
     })
    .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) { 
            // NO
        }
     })
    .setIcon(android.R.drawable.ic_dialog_alert)
     .show();

How to set the start location of FolderBrowserDialog in C# and VB.NET

To set the start location of FolderBrowserDialog in C# and VB.NET you can use the following snippet.
To do so, simply set the SelectedPath Value to the path you want.

Sample C#

MyFolderBrowserDialog.SelectedPath = @"C:\Test";

Sample VB.NET

MyFolderBrowserDialog.SelectedPath = "C:\Test"

How to choose a font using FontDialog in C# and VB.NET

To choose a font using FontDialog in C# and VB.NET you can use the following snippet.

Sample C#

using (var dialog = new FontDialog())
{
	if (dialog.ShowDialog() != DialogResult.Cancel)
	{
		textBox1.Font = dialog.Font;
	}
}

Sample VB.NET

Using dialog = New FontDialog()
	If dialog.ShowDialog() <> DialogResult.Cancel Then
		textBox1.Font = dialog.Font
	End If
End Using

How to select a file using OpenFileDialog in C# and VB.NET

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

Sample C#

private string SelectFileDialog(string initialDirectory=@"C:\")
{
	using (var dialog = new OpenFileDialog())
	{
		dialog.Filter = @"All files (*.*)|*.*";
		dialog.InitialDirectory = initialDirectory;
		dialog.Title = @"Select a file";
		return (dialog.ShowDialog() == DialogResult.OK) ? dialog.FileName : string.Empty;
	}
}

Sample VB.NET

Private Function SelectFileDialog(Optional initialDirectory As String = "C:\") As String
	Using dialog = New OpenFileDialog()
		dialog.Filter = "All files (*.*)|*.*"
		dialog.InitialDirectory = initialDirectory
		dialog.Title = "Select a file"
		Return If((dialog.ShowDialog() = DialogResult.OK), dialog.FileName, String.Empty)
	End Using
End Function

How to choose a color using ColorDialog in C# and VB.NET

To choose a color using ColorDialog in C# and VB.NET you can use the following snippet.

Sample C#

using (var colorDialog = new ColorDialog())
{
	if (colorDialog.ShowDialog() != DialogResult.Cancel)
	{
		var colorChosen = colorDialog.Color;
		textBox1.ForeColor = colorChosen;
		textBox1.BackColor = colorChosen;
	}
}

Sample VB.NET

Using colorDialog = New ColorDialog()
	If colorDialog.ShowDialog() <> DialogResult.Cancel Then
		Dim colorChosen = colorDialog.Color
		textBox1.ForeColor = colorChosen
		textBox1.BackColor = colorChosen
	End If
End Using