How do I set the company name that is returned by System.Windows.Forms.Application.CompanyName
This is an assembly attribute. The VS development environment sets it in the AssemblyInfo.cs (vb) file. If you open that file, you will see a block of assembly attributes that you can set, including company and version numbers. [assembly: AssemblyCompany(‘Syncfusion, Inc.’)]
How can I draw outside my WIndow
You have to get a handle to the desktop and draw on the desktop. This means that whatever you draw will not be automatically refreshed when another window is dragged over it. [DllImport(‘User32.dll’)] public extern static System.IntPtr GetDC(System.IntPtr hWnd); private void button1_Click(object sender, System.EventArgs e) { System.IntPtr DesktopHandle = GetDC(System.IntPtr.Zero); Graphics g = System.Drawing.Graphics.FromHdc(DesktopHandle); g.FillRectangle(new SolidBrush(Color.Red),0,0,100,100); } from a microsoft.public.dotnet.framework.windowsforms posting by Lion Shi (MS)
How do I prevent the Designer-Grid from being drawn on my Container Control during design-time?
You can do so by overriding the DrawGrid property in your custom designer: public class MyContainerDesigner : ParentControlDesigner { protected override /*ParentControlDesigner*/ bool DrawGrid { get { if (!this.disableDrawGrid) return base.DrawGrid; else return false; } } }
How can I show a form without making it active
Normally when you make a Form visible by setting the Visible property to true, it will show the form and set the focus too. In some cases however, you do not want it to take focus until the user clicks on it. To get this behavior, do the following utility code: When you want to show a form without activating it: UtilFuncs.SetVisibleNoActivate(myForm, true); // true to show. When you want to hide it: UtilFuncs.SetVisibleNoActivate(myForm, false); // false to hide. public class UtilFuncs { [DllImport(‘USER32.dll’)] extern public static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags) ; public const int HWND_TOPMOST = -1; // 0xffff public const int SWP_NOSIZE = 1; // 0x0001 public const int SWP_NOMOVE = 2; // 0x0002 public const int SWP_NOZORDER = 4; // 0x0004 public const int SWP_NOACTIVATE = 16; // 0x0010 public const int SWP_SHOWWINDOW = 64; // 0x0040 public const int SWP_HIDEWINDOW = 128; // 0x0080 public const int SWP_DRAWFRAME = 32; // 0x0020 public static void ShowWindowTopMost(IntPtr handle) { SetWindowPos(handle, (IntPtr)HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_SHOWWINDOW); } public static void SetVisibleNoActivate(Control control, bool visible) { if(visible) { ShowWindowTopMost(control.Handle); control.Visible = true; } else control.Visible = false; } }
When I get the SelectedNode in the treeview’s Click event, it is the old selection. How do I get the newly selected node
Try using the AfterSelect event instead of the Click event. The Click event is inherited from Control.Click and occurs before the new selection is set into SelectedNode. The AfterSelect event is fired after the newly selected node is placed in the SelectedNode property. This code illustrates these events. private void treeView2_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { TreeNode node = treeView2.SelectedNode; Console.WriteLine(‘AfterSelect:’ + node.ToString());//from tree Console.WriteLine(‘AfterSelect:’ + e.Node.ToString());//from event args } private void treeView2_Click(object sender, System.EventArgs e) { TreeNode node = treeView2.SelectedNode; if(node == null) Console.WriteLine(‘Click: (none)’); else Console.WriteLine(‘Click: ‘ + node.ToString()); }