Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

Browse by Tags

All Tags » General » Using Controls (RSS)

Sorry, but there are no more tags available to filter with.

  • What are some user interface limitations while running code in the Internet Zone?

    1) Cannot override methods like WndProc, ProcessCmdKey, etc in a derived Control. The class ref for a particular property will let you know about the permission requirements. 2) Cannot call Control.Parent. 3) Cannot call Control.Focus() method. Contributed...
  • What are some problem areas when using Windows Forms Controls in Internet Explorer?

    The issues listed here are pertaining to code running in IE in the default Internet Zone. 1) You cannot view Controls inside IE using the 1.0 framework (when running with the permissions in the default Internet Zone). This is however possible with the...
  • How do I host Windows Forms Controls in Internet Explorer?

    You cannot use a WinForms Control directly in IE, you will have to instead derive from it and then use the derived instance from a custom assembly. These articles introduce the topic: Host Secure, Lightweight Client-Side Controls in Microsoft Internet...
  • How do I programmatically manipulate Anchor styles?

    You can do this using the bitwise operators. In C# the bitwise operators are & , | and ^ ; in VB they are And (or &), Or and Xor (or ^). Here is code that will toggle whether label1 is anchored on the left. [C#] using System.Windows.Forms; private...
  • How do I make a control occupy all the client area of a Form?

    private void Form1_Load( object sender, EventArgs e ) { Bitmap newBmp = new Bitmap(100, 100); Graphics g = Graphics.FromImage(newBmp); g.FillRectangle(new SolidBrush(Color.Red), 0, 0, 33, 100); g.FillRectangle(new SolidBrush(Color.White), 34, 0, 33, 100...
  • Where do I find an ImageMap-style control?

    Where do I find an ImageMap-style control? There isn't an ImageMap-style control in the .NET Framework Class Library. However, the article C# Windows Forms ImageMap Control by Ryan LaNeve, September 2002, on The Code Project provides a control with...
  • How do I change the cursor for a control?

    button1.Cursor = new Cursor( @"C:\winnt\cursors\hnodrop.cur" ); Contributed from George Shepherd's Windows Forms FAQ
  • How do I programmatically add controls to a form and ensure they are displayed?

    The controls that I've try to add to my form at runtime don't show up. What's wrong? Make sure you implemented and executed code similar to the InitializeComponent method that VS adds to your Windows Forms project for controls added during...
  • How do I dynamically load a control from an assembly (or DLL)?

    You use System.Reflection to dynamically load a control. This sample loads the SpecControls.ColorControl from SpecControls.dll. [C#] using System.Reflection; Assembly assembly = Assembly.LoadFrom( "SpecControls.dll" ); Type t = assembly.GetType...
  • How do I add a control to a Window Form at runtime?

    There are three steps to adding a control at runtime. Create the control. Set control properties. Add the control to the Form's Controls collection. In general, if you need help on exactly what code you need to add, just look at the code generated...
  • How do I share a common event handler across multiple controls?

    In VB6, I used control arrays to have a common handler handle events from several controls. How can I do this in Windows Forms? You can specify events from different controls be handled by a single method. When you define your handler, you can list several...
  • How do I get an HWND for a form or control?

    See the Control.Handle property which returns the HWND. Be careful if you pass this handle to some Win32 API as Windows Forms controls do their own handle management so they may recreate the handle which would leave this HWND dangling. Shawn Burke, Microsoft
  • Why are URLs case sensitive when hosting controls in Internet Explorer?

    I am using a Windows Forms control in an Internet Explorer (IE) page. When IE downloads the control, it is distinguishing between upper- and lower-case letters in the web site URL. When I use the same site with different casing - such as http://111.1...


Page view counter