Can I drag and drop code snippets using the VS.NET IDE?
Yes, in Code View you can select and drag code to aTab (General Tab) in the ToolBox and then you can drag the code from the Tab to the desired location.
How can I enable the mnemonics (underline) to show when my application is launched?
Usually the underline appears only after you press the ALT Key, but you can enable it by changing the Operating System Settings. On Windows XP, Right Click Desktop to bring up the Display Properties Dialog and then choose Appearance tab and then the Effects Button and uncheck the checkbox ‘Hide Underlined letters for keyboard navigation until I press the ALT Key’.
How can I display a pop up a confirmation dialog when the user closes the form?
You can listen to the Form’s Closing event, where you can display a MessageBox as show below: [C#] private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (MessageBox.Show(‘Do you want to close the application?’, ‘Close Application’, MessageBoxButtons.YesNo) == DialogResult.No) e.Cancel = true; } [VB.NET] Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) If MessageBox.Show(‘Do you want to close the application?’,’Close Application’,MessageBoxButtons.YesNo) = DialogResult.No Then e.Cancel = True End If End Sub
How can I shut down/restart the OS from my Windows Forms Application?
You could do this using the WMI Classes in the .NET Framework or use WindowsController available at http://www.mentalis.org
How can I move a Borderless form?
This code snippet shows how you can move a borderless form. [C#] public const int WM_NCLBUTTONDOWN = 0xA1; public const int HTCAPTION = 0x2; [DllImport(‘User32.dll’)] public static extern bool ReleaseCapture(); [DllImport(‘User32.dll’)] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0); } }