Results 1 to 1 of 1

Thread: Conditional Property in Design-Time

  1. #1
    MarcosMendes is offline C# Forum Newbie
    .NET Framework
    .NET 4.5
    Join Date
    Oct 2016
    Posts
    1
    Rep Power
    0

    Question Conditional Property in Design-Time

    Hi friends,




    I'm developing a C # component that inherits from TextBox. A simple component, with validations and masks only.



    The problem is that I have a Data Type property, with several possible attributes (CPF, CNPJ, RG, Voter Title, and others) and the General attribute that is used case of the programmer does not want to enable validations or masks. In this case, the component would behave like a normal TextBox, only with extra component design options.


    Thus, I would like the Boolean Validation and Mask properties to be disabled [Enable (false)] for the General Data Type property, but to be enabled [Enable (true)] for the other options ...



    I've never worked with design-time development before so I have no many idea how I can do it.

    I'm attaching an image that may help you understand what I'm needing.


    In it the Mask property is enabled for change. What I need is that it is not enabled, unless the Data Type property has an attribute other than General.

    I tried to create the interface, the below, for the Validation property (which has the same scope and must have the same Mask behavior (I have not put it in the Interface yet, it is outside, according to the code), but that way, the Validation property does not appear in the properties panel as you can see in the attached image.


    Code:
    #region TESTES
            
            public interface IReadOnlyProperties
            {
                bool ValidationPropertie { get; set; }
            }
    
    
            public class IsReadOnly : IReadOnlyProperties
            {
                private bool _validationStatus;
                [ReadOnly(true)]
                [Browsable(true)]
                [DisplayName("Validation")]
                [DefaultValue(false)]
    
    
                public bool ValidationPropertie
                {
                    get { return _validationStatus; }
                    set { _validationStatus = value; }
                }
                //public bool ValidationPropertie { get; set; }
            }
    
    
            public class IsNotReadOnly : IReadOnlyProperties
            {
                private bool _validationStatus;
    
    
                [ReadOnly(false)]
                [Browsable(true)]
                [DisplayName("Validation")]
                [DefaultValue(false)]
    
    
                public bool ValidationPropertie
                {
                    get { return _validationStatus; }
                    set { _validationStatus = value; }
                }
                //public bool ValidationPropertie { get; set; }
    
    
            }
    
    
            public void TESTE()
            {
                MessageBox.Show("Entrou em Teste");
    
    
                IReadOnlyProperties instance = null;
                if (DataType != myT_TextBox_Component._DataType.Geral)
                {
                    instance = new IsReadOnly();
                }
                else
                {
                    instance = new IsNotReadOnly();
                }
    
    
            }
    
    
            #endregion TESTES

    Code:
    
    
    
    private bool _maskStatus;
    
    
                [Browsable(true)]
                [DisplayName("Mask")]
                [DefaultValue(false)]
                public bool MaskPropertie
                {
                    get { return _maskStatus; }
                    set { _maskStatus = value; }
                }
    Attached Images Attached Images

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •