How to I introduce culture information into formatted strings
You use the CultureInfo class found in the System.Globalization namespace. DateTime dt = DateTime.Now; textBox2.Text = dt.ToString('D', new CultureInfo('de-DE')); textBox3.Text = dt.ToString('D', new CultureInfo('fr-FR'));
How do I set the default button for a form
Set the form’s AcceptButton property. You can do this either through the designer, or through code such as Form1.AcceptButton = button1;
How do I beep the computer’s speaker in a Windows Form application
There is no Windows Form function to beep your computer’s speaker. But you can just invoke the Win32 API MessageBeep. using System.Runtime.InteropServices; ... [DllImport('user32.dll')] public static extern int MessageBeep(uint n); private void button2_Click(object sender, System.EventArgs e) { MessageBeep(0x0); } Another method (suggested by msauper@sauper.com on microsoft.public.dotnet.framework.windowsforms) Reference the VB.NET runtime support and just use the Beep() method. The method is in: Microsoft.Visual Basic.NET Runtime The method is: Microsoft.VisualBasic.Interaction.Beep();
How do I make the arrow keys be accepted by a control (such as a button) and not handled automatically by the framework’s focus management
By default, the arrow keys are not handled by a control’s key processing code, but instead are filtered out for focus management. Hence, the control’s KeyDown, KeyUp and KeyPressed events are not hit when you press an arrow. If you want your control to handle these keyboard events, you tell the framework by overriding your control’s IsInputKey method. protected override bool IsInputKey(Keys key) { switch(key) { case Keys.Up: case Keys.Down: case Keys.Right: case Keys.Left: return true; } return base.IsInputKey(key); }
How can I get a string that contains RTF format codes into a RichTextBox
Use the Rtf property of the control. richTextBox1.Rtf = @'{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}\viewkind4\uc1\pard\b\i\f0\fs20 This is bold italics.\par }';