Sugerir tradução
 
Outras sugestões:

progress indicator
Sem sugestões.
Clique para classificar e enviar comentários
MSDN
Biblioteca MSDN
Visual Studio 2008
Visual Studio
 Como: Executar inicialização Person...

  Ativar exibição de largura de banda baixa
Exibir Conteúdo: Lado a LadoExibir Conteúdo: Lado a Lado
Este conteúdo foi traduzido automaticamente e pode ser editado pelos membros da comunidade. Para melhorar a qualidade da tradução, clique no link Editar associado à frase que deseja modificar.
Windows Forms Programming
How to: Perform Custom Initialization for Controls in Design Mode

You can use your custom designer to initialize components and controls as they are created by the design environment.

The following code example demonstrates how to initialize a control when it is created by the design environment. This creation occurs when you drag an instance of the control onto your form, and it also occurs when you start the designer for your form. For a complete explanation of this code example, see How to: Extend the Appearance and Behavior of Controls in Design Mode.

Visual Basic
' This demonstrates changing the appearance of a control while
' it is being designed. In this case, the BackColor property is
' set to LightBlue. 
Public Overrides Sub InitializeNewComponent( _
ByVal defaultValues As IDictionary)

    MyBase.InitializeNewComponent(defaultValues)

    Dim colorPropDesc As PropertyDescriptor = _
    TypeDescriptor.GetProperties(Component)("BackColor")

    If colorPropDesc IsNot Nothing AndAlso _
       colorPropDesc.PropertyType Is GetType(Color) AndAlso _
       Not colorPropDesc.IsReadOnly AndAlso _
       colorPropDesc.IsBrowsable Then
        colorPropDesc.SetValue(Component, Color.LightBlue)
    End If
End Sub

C#
// This demonstrates changing the appearance of a control while
// it is being designed. In this case, the BackColor property is
// set to LightBlue. 

public override void InitializeNewComponent(IDictionary defaultValues)
{
    base.InitializeNewComponent(defaultValues);

    PropertyDescriptor colorPropDesc = 
        TypeDescriptor.GetProperties(Component)["BackColor"];

    if (colorPropDesc != null &&
        colorPropDesc.PropertyType == typeof(Color) &&
        !colorPropDesc.IsReadOnly &&
        colorPropDesc.IsBrowsable)
    {
        colorPropDesc.SetValue(Component, Color.LightBlue);
    }
}

When the design environment creates an instance of your control or component, it calls your designer's InitializeNewComponent method. In the previous code example, the control's BackColor property is set by using a PropertyDescriptor.

When you make changes to the design-time aspects of a component, you need to rebuild the control project. In addition, if there is another Windows Forms project that is currently open and uses this component, you will probably need to refresh the project to see the changes. Typically, you need to close and reopen the design window containing the component.

Formulários do Windows programação
Como: Executar inicialização Personalizars para controles no modo Design

Você pode usar seu designer Personalizar ao inicializar componentes e controles quando são criados pelo ambiente de design.

O exemplo de código a seguir demonstra como inicializar um Controlarar quando ele é criado pelo ambiente de design. Essa criação ocorre quando você arrasta uma instância do Controlarar para seu formulário, e ele também ocorre ao iniciar o designer do formulário. Para uma explicação completa deste exemplo de código, consulte Como: Estender a aparência e comportamento de controles no modo Design.

Visual Basic
' This demonstrates changing the appearance of a control while
' it is being designed. In this case, the BackColor property is
' set to LightBlue. 
Public Overrides Sub InitializeNewComponent( _
ByVal defaultValues As IDictionary)

    MyBase.InitializeNewComponent(defaultValues)

    Dim colorPropDesc As PropertyDescriptor = _
    TypeDescriptor.GetProperties(Component)("BackColor")

    If colorPropDesc IsNot Nothing AndAlso _
       colorPropDesc.PropertyType Is GetType(Color) AndAlso _
       Not colorPropDesc.IsReadOnly AndAlso _
       colorPropDesc.IsBrowsable Then
        colorPropDesc.SetValue(Component, Color.LightBlue)
    End If
End Sub

C#
// This demonstrates changing the appearance of a control while
// it is being designed. In this case, the BackColor property is
// set to LightBlue. 

public override void InitializeNewComponent(IDictionary defaultValues)
{
    base.InitializeNewComponent(defaultValues);

    PropertyDescriptor colorPropDesc = 
        TypeDescriptor.GetProperties(Component)["BackColor"];

    if (colorPropDesc != null &&
        colorPropDesc.PropertyType == typeof(Color) &&
        !colorPropDesc.IsReadOnly &&
        colorPropDesc.IsBrowsable)
    {
        colorPropDesc.SetValue(Component, Color.LightBlue);
    }
}

Quando o ambiente de design cria uma instância do seu Controlarar ou componente, ele chama InitializeNewComponent método seu designer. No exemplo de código anterior, a propriedade do Controlarar BackColor é definida usando um PropertyDescriptor.

Quando você alterar os aspectos de tempo de design de um componente, você precisará Recompilar o projeto de Controlarar. Além disso, se houver outro projeto de Windows Forms que é Abrir no momento e usa esse componente, você provavelmente precisará atualizar o projeto para ver as alterações. Normalmente, você precisará fechar e reabrir a janela de design que contém o componente.

Conteúdo da Comunidade   O que é Conteúdo da Comunidade?
Adicionar novo conteúdo RSS  Anotações
Processing
© 2009 Microsoft Corporation. Todos os direitos reservados. Termos de Uso  |  Marcas Comerciais  |  Política de Privacidade
Page view tracker