Browse by Tags
All Tags » Custom Controls » General (RSS)
Sorry, but there are no more tags available to filter with.
-
|
See the DesignModeDialog sample. This sample is a component, much like the common dialogs, that has a ShowDialog method. When invoked, ShowDialog takes a snapshot of the parent form, clones all the controls and creates a new designer form with the controls...
|
-
|
The new DesignSurface class drastically simplifies the code necessary to host a designer in your own application. The following lines of code show the most simple designer that can be created. Note: to run this code, a reference to System.Design.dll will...
|
-
|
You can do this in different ways explained below. In all the cases the bitmap or icon should follow these rules: The bitmap or icon dimension should be 16x16 with 16 colors. The bottom-left pixel color will be assumed to be the transparent color. Technique...
|
-
|
Provide ShouldSerialize and Reset Methods along with your property. Example: private bool ShouldSerializeFont() { return this.bFontSet; } private void ResetFont() { this.localFont = null; } Contributed from George Shepherd's Windows Forms FAQ
|
-
|
For example, if you have a custom type: public class CustomSize { public int Width { get { /*...*/ } set { /*...*/ } } public int Height { get { /*...*/ } set { /*...*/ } } } And you want to the Width and Height properties to appear in that order, then...
|
-
|
If you have a custom data type like this: public class CustomSize { public int Width { get { /*...*/ } set { /*...*/ } } public int Height { get { /*...*/ } set { /*...*/ } } } Then write this: public class CustomSizeConverter : ExpandableObjectConverter...
|
-
|
Check the Form.DesignMode property. But note that when in Visual Inheritance mode (designing a derived form), your control's DesignMode property will be true when the base form's constructor gets executed in the design-time. To workaround this...
|
-
|
Type converters let you convert one type to another type. Each type that you declare can optionally have a TypeConverter associated with it using the TypeConverterAttribute. If you do not specify one the class will inherit a TypeConverter from its base...
|
-
|
Provide the followoing attributes to your Property: [ Browsable( false ), EditorBrowsable( EditorBrowsableState.Always ) ] public bool CustomProperty{ get{} set{} } Contributed from George Shepherd's Windows Forms FAQ
|
-
|
Set the Browsable attribute on the new property that hides the existing one. Here is a code snippet that hides the WordWrap property in the derived TextBox. [C#] public class CustomTextBox : TextBox { [ Browsable( false ) ] public new bool WordWrap {...
|
-
|
Use the DesignTimeVisible attribute set to false. [ DesignTimeVisible( false ) ] You can still provide a TypeConverter to make it participate in designer Serialization. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
Use the ToolboxItem attribute set to false on your component or control class. This will prevent it from appearing in the Toolbox. [ ToolboxItem( false ) ] public class MyComponent : Component{..} Contributed from George Shepherd's Windows Forms FAQ
|
-
|
When you call the Focus method on a control, the control must be visible; otherwise focus will not be set. For example, if you call Focus on a control in Form_Load then focus will not be set. Instead consider setting the control's TabIndex property...
|
-
|
The .NET Framework Class Library does not provide a method to determine which control has keyboard focus, but you can invoke a Win32 API function to do this. Here's a custom form class that adds a GetFocusControl method to retrieve the .NET control...
|
-
|
Override the control's WndProc method. This sample shows a custom control that is a ComboBox that discards the WM_KEYUP message. [C#] using System.Windows.Forms; public class ComboBoxWithNoKeyUp : ComboBox { private const int WM_KEYUP = 0x101; protected...
|
-
|
See Developing a Simple Windows Forms Control from .NET Framework Developer's Guide for a walk-through about creating Windows Forms custom controls. Tom Krueger, Microsoft
|