Class CardLayout
Represents the LayoutManager that lays out the children as "Cards".
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.Tools
Assembly: Syncfusion.Shared.Base.dll
Syntax
public class CardLayout : LayoutManager, IExtenderProvider, ILayoutManager, ISupportInitialize
Remarks
Each child component is a "Card" with a name attached to it. The CardLayout will display only one Card at a time, allowing you to flip through it. Use the First(), Last(), Next(), Previous(), and Show(String) methods to do so.
The LayoutMode property lets you specify whether to lay out the children based on their preferred size or make them fill the parent's client rectangle.
The SetCardName(Control, String) method will expect you to pass a string value indicating the name of the Card as the constraint.
Setting the same Card name for more than one component will result in unforseen conflicts.
During design-time, you can change the order of the child controls being laid out by moving them around using the "Bring to Front" and "Send to Back" verbs provided by the control designer.
Take a look at the LayoutManager class documentation for more information on LayoutManager in general.
Examples
Here is some sample code that tells you how to initialize a CardLayout manager:
// Binding a Control to the CardLayout manager programmatically.
this.cardLayout1 = new CardLayout();
// Set the container control; all the child controls of this container control are
// automatically registered as children with the manager and get default card names.
this.cardLayout1.ContainerControl = this.panel1;
// Set custom card names to replace default card names.
this.cardLayout1.SetCardName(this.label1, "MyCard1");
// To select a card manually, use the SelectedCard property.
this.cardLayout1.SelectedCard = "MyCard1";
// Or move through the cards like this:
this.cardLayout1.Next();
this.cardLayout1.Previous();</code></pre>
Also, take a look at the project in Tools/Samples/Quick Start/LayoutManager for an example.
Constructors
CardLayout()
Overloaded. Creates a new instance of the CardLayout class and sets its defaults.
Declaration
public CardLayout()
CardLayout(IContainer)
Creates a new instance of the CardLayout class and adds itself to the specified container.
Declaration
public CardLayout(IContainer container)
Parameters
| Type | Name | Description |
|---|---|---|
| System.ComponentModel.IContainer | container | The logical System.Windows.Forms.ContainerControl parent into which to add itself. |
Remarks
This constructor is used by the design-time to add a component to the form's System.ComponentModel.IContainer field so that it gets Disposed when the form gets Disposed.
Note that this is not the same as the LayoutManager's container control.
CardLayout(Control)
Creates a new instance of the CardLayout class and sets its System.Windows.Forms.ContainerControl.
Declaration
public CardLayout(Control container)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Control | container |
Fields
CardNameBase
Indicates the Base Name of the card.
Declaration
protected string CardNameBase
Field Value
| Type |
|---|
| System.String |
Properties
LayoutMode
Gets or sets the CardLayoutMode.
Declaration
public CardLayoutMode LayoutMode { get; set; }
Property Value
| Type | Description |
|---|---|
| CardLayoutMode | The current CardLayoutMode. Default is CardLayoutMode.Default. |
NextCardIndex
Returns the index of the next card that will be shown when the Next() method gets called.
Declaration
public int NextCardIndex { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | A valid index into the list returned by the GetControls() method; -1 if a next card is not available. |
Remarks
This property will return the first card if the currently selected card is the last card.
PreviousCardIndex
Returns the index of the previous card that will be shown when the Previous() method gets called.
Declaration
public int PreviousCardIndex { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | A valid index into the list returned by the GetControls() method; -1 if a previous card is not available. |
Remarks
This property will return the last card if the currently selected card is the first card.
SelectedCard
Gets or sets the current Card's name.
Declaration
public string SelectedCard { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String | The current Card's name. |
Methods
AddLayoutComponent(Control, Object)
Overridden. See AddLayoutComponent(Control, Object).
Declaration
public override void AddLayoutComponent(Control childControl, object constraints)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Control | childControl | The child control which is added to the Layout |
| System.Object | constraints | The Card Name as string |
Overrides
EndInit()
Ends designer initialization.
Declaration
public override void EndInit()
Overrides
First()
Shows the first Card.
Declaration
public void First()
GetCardName(Control)
Returns the Card name of a child component.
Declaration
public string GetCardName(Control control)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Control | control | The child component whose Card name is to be retrieved. |
Returns
| Type | Description |
|---|---|
| System.String | The Card name as string. |
GetCardNames()
Returns an array containing the Card names as strings.
Declaration
public ArrayList GetCardNames()
Returns
| Type | Description |
|---|---|
| System.Collections.ArrayList | An ArrayList of Card names. |
GetComponentFromName(String)
Returns an associated control given a Card name.
Declaration
public Control GetComponentFromName(string cardName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cardName | The card name whose control to retrieve. |
Returns
| Type | Description |
|---|---|
| System.Windows.Forms.Control | A control associated with the card name. |
GetCurrentVisibleChild()
Returns the current active Card.
Declaration
protected Control GetCurrentVisibleChild()
Returns
| Type | Description |
|---|---|
| System.Windows.Forms.Control | The control representing the card. |
GetMaintainAspectRatio(Control)
Returns the value for maintaining aspect ratio based on the control's PreferredSize.
Declaration
public virtual bool GetMaintainAspectRatio(Control control)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Control | control | The control whose aspect ratio setting is to be known. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the aspect ratio should be maintained; false otherwise. |
GetNewCardName()
Generates a new unique name for a card that could be added to this CardLayout.
Declaration
public virtual string GetNewCardName()
Returns
| Type | Description |
|---|---|
| System.String | A card name unique within this LayoutManager. |
Last()
Shows the last Card in the list.
Declaration
public void Last()
LayoutContainer()
Overridden. See LayoutContainer().
Declaration
public override void LayoutContainer()
Overrides
MinimumLayoutSize()
Overridden. See MinimumLayoutSize().
Declaration
public override Size MinimumLayoutSize()
Returns
| Type |
|---|
| System.Drawing.Size |
Overrides
Next()
Shows the next Card in the list.
Declaration
public void Next()
OnContainerControlChanged(EventArgs)
Overridden. See OnContainerControlChanged(EventArgs).
Declaration
protected override void OnContainerControlChanged(EventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventArgs | e |
Overrides
OnControlAdded(Object, ControlEventArgs)
Overridden. See OnControlAdded(Object, ControlEventArgs).
Declaration
protected override void OnControlAdded(object sender, ControlEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | |
| System.Windows.Forms.ControlEventArgs | e |
Overrides
OnRestoreChildPosition(CancelEventArgs)
Declaration
protected virtual void OnRestoreChildPosition(CancelEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.ComponentModel.CancelEventArgs | e |
PreferredLayoutSize()
Overridden. See PreferredLayoutSize().
Declaration
public override Size PreferredLayoutSize()
Returns
| Type |
|---|
| System.Drawing.Size |
Overrides
Previous()
Shows the previous Card in the list.
Declaration
public void Previous()
RemoveLayoutComponent(Control)
Overridden. See RemoveLayoutComponent(Control).
Declaration
public override void RemoveLayoutComponent(Control childControl)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Control | childControl | The child control which is need to remove from layout |
Overrides
ResetLayoutInfo()
Overridden. See ResetLayoutInfo().
Declaration
protected override void ResetLayoutInfo()
Overrides
SetCardName(Control, String)
Sets the Card name for a child component.
Declaration
public void SetCardName(Control control, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Control | control | The child component whose Card name is to be set. |
| System.String | value | The Card name as string. |
Remarks
Use this method to change the card name of a component once set using AddLayoutComponent(Control, Object). Setting a NULL or empty string will also remove the component from the layout list.
SetMaintainAspectRatio(Control, Boolean)
Sets the value for maintaining aspect ratio based on the control's PreferredSize.
Declaration
public virtual void SetMaintainAspectRatio(Control control, bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Control | control | The control to associate the aspect ratio setting. |
| System.Boolean | value | True to maintain aspect ratio. False otherwise. |
Remarks
Use this method to specify whether or not the control will be drawn maintaining its aspect ratio based on the control's PreferredSize. Applicable only when the LayoutMode property is set to CardLayoutMode.Default.
Show(String)
Shows a Card by name.
Declaration
public void Show(string cardName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cardName | The Card's name. |
ValidateHiddenStates()
Validates hidden states.
Declaration
public void ValidateHiddenStates()
Events
RestoreChildPosition
This event is raised in LayoutContainer() method before applying new bounds.
Declaration
public event CardLayout.RestoreChildPositionEventHandler RestoreChildPosition
Event Type
| Type |
|---|
| CardLayout.RestoreChildPositionEventHandler |