DesignerAutoFormatCollection.Add(DesignerAutoFormat) 方法

定义

将指定的 DesignerAutoFormat 对象添加到集合末尾。

public:
 int Add(System::Web::UI::Design::DesignerAutoFormat ^ format);
public int Add (System.Web.UI.Design.DesignerAutoFormat format);
member this.Add : System.Web.UI.Design.DesignerAutoFormat -> int
Public Function Add (format As DesignerAutoFormat) As Integer

参数

format
DesignerAutoFormat

DesignerAutoFormat 的一个实例。

返回

Int32

集合中添加了格式的位置的索引。

示例

下面的代码示例演示如何创建对象并将其添加到DesignerAutoFormatAutoFormats自定义设计器的属性。

// The collection of AutoFormat objects for the IndentLabel object
public override DesignerAutoFormatCollection AutoFormats
{
    get
    {
        if (_autoFormats == null)
        {
            // Create the collection
            _autoFormats = new DesignerAutoFormatCollection();

            // Create and add each AutoFormat object
            _autoFormats.Add(new IndentLabelAutoFormat("MyClassic"));
            _autoFormats.Add(new IndentLabelAutoFormat("MyBright"));
            _autoFormats.Add(new IndentLabelAutoFormat("Default"));
        }
        return _autoFormats;
    }
}
' The collection of AutoFormat objects for the IndentLabel object
Public Overrides ReadOnly Property AutoFormats() As DesignerAutoFormatCollection
    Get
        If _autoFormats Is Nothing Then
            ' Create the collection
            _autoFormats = New DesignerAutoFormatCollection()

            ' Create and add each AutoFormat object
            _autoFormats.Add(New IndentLabelAutoFormat("MyClassic"))
            _autoFormats.Add(New IndentLabelAutoFormat("MyBright"))
            _autoFormats.Add(New IndentLabelAutoFormat("Default"))
        End If

        Return _autoFormats
    End Get
End Property

注解

该方法 Add 将指定的 DesignerAutoFormat 对象添加到集合的末尾。 若要在特定索引位置将对象添加到 DesignerAutoFormat 集合中,请使用 Insert 该方法。

适用于

另请参阅