Browse by Tags
All Tags » Custom Controls » Appearance (RSS)
Sorry, but there are no more tags available to filter with.
-
|
We have a small sample that shows how to do this. Download PropTab.zip . After you download and unzip the sample, build the project. Both the control assembly and a small driver assembly get built. After that add the control to your toolbox using 'Customise...
|
-
|
I set a control's Visible property to true and in the next statement, it returns false. Why doesn't setting the Visible property work? A control's Visible property depends on its parent control's Visible property, if it has a parent control...
|
-
|
You should override the WndProc method in the control and process the WM_DISPLAYCHANGE message. You could also do this at the form level. For details on overriding the WndProc method, see How do I process Windows messages in a control? in this FAQ. Contributed...
|
-
|
Here is a method using Reflection to achieve this. [ DllImport( "user32.dll" ) ] private extern static int SendMessage( IntPtr hwnd, uint msg, int wParam, int lParam); object o = typeof( ToolTip ).InvokeMember( "Handle", BindingFlags...
|
-
|
Include a \n as part of the tiptext. toolTip1.SetToolTip( button1, "Press for\ninformation..." ); Contributed from George Shepherd's Windows Forms FAQ
|
-
|
From within the designer: 1) From the ToolBox, drap a ToolTip control to your form. 2) Check the properties of this toolTip1 object to make sure Active is set to true. 3) Click on your control (e.g., a button), and in its Property page, set the ToolTip...
|
-
|
One generic way for all controls is to get the difference between the ClientRectangle's width and the Control.Bounds' width. That should give the border width (and in general the non-client area width). Use the same approach for height. Contributed...
|
-
|
Override the custom control's CreateParams property as shown in this sample. protected override CreateParams CreateParams { get { CreateParams cparams = base.CreateParams; cparams.ExStyle &= ~512; cparams.Style &= ~8388608; // WS_BORDER cparams...
|
-
|
You will have to first provide some space in the NC area by setting the WS_BORDER flag in CreateParams and then draw the border yourself by listening to the WM_NCPAINT message in your Control, as follows: protected override CreateParams CreateParams ...
|
-
|
Providing a border in the non-client region of a control, rather than in the ClientRectangle, has several advantages. If you include a scrollbar in the control, the scrollbar will appear inside the border. If you draw the border in the client area, the...
|
-
|
Override the control's OnPaint method. Here is a sample custom Button. [C#] using System.Drawing; using System.Windows.Forms; public class ButtonWithCustomBorder : Button { protected override void OnPaint( PaintEventArgs e ) { base.OnPaint( e ); Color...
|
-
|
To draw on any hwnd, you need to get a Graphics object from that hwnd. Once you have the Graphics object, you can then use its methods to draw. Of course, since this drawing is not done in the Paint handler, it will not be automatically refreshed when...
|
-
|
Handle the Paint event for your control or form. private void Form1_Paint( object sender, PaintEventArgs e ) { Graphics g = e.Graphics; Pen pen = new Pen( Color.White, 2 ); SolidBrush redBrush = new SolidBrush( Color.Red ); g.DrawEllipse( pen, 100, 150...
|
-
|
By default a control's background color will be the same as the container's background color. You can set the control's BackColor property to Transparent in the Designer. Select the control in the Designer, select the BackColor property in...
|
-
|
Make sure that you include the manifest file that will enable XP themes support for you application. Then the icons with alpha channel will draw semi-transparently. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
Why do the XP Icons when drawn using Graphics.DrawImage not draw transparently? Note that it's only the ImageList class that can draw an Icon with alpha channel properly. So, instead of using the Graphics.DrawImage method, first associate this icon...
|
-
|
This is possible if the Control is drawn by the system, rather than by the framework. This is the case for example with the Label control when its set to FlatStyle.System. You should then set to to something else other than System for your transparent...
|
-
|
Sometimes the framework will throw an exception if you try to set the bg color to be transparent. This is because the Control doesn't support transparent colors. To work around this you should call this method from within the Control: SetStyle( ControlStyles...
|
-
|
The Window.Forms framework offers support for double buffering to avoid flickers through ControlStyles. Double buffering is a technique that attempts to reduce flicker by doing all the drawing operations on an off-screen canvas, and then exposing this...
|
-
|
Use the DrawImageDisabled method of the ControlPaint class. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
When I try to set a particular font style, say italics, I get an error message "Property cannot be assigned to -- it is read only". Code such as the following will not work . control.Font.Italic = true; Instead create a new Font object and set...
|
-
|
Use the Font property for the control along with the Font class in the System.Drawing namespace. button1.Font = new Font ( "Courier", 10, FontStyle.Bold ); Contributed from George Shepherd's Windows Forms FAQ
|
-
|
How do I programmatically change the color of a control? Set the control's BackColor and ForeColor properties. Contributed from George Shepherd's Windows Forms FAQ
|