如何在设计时隐藏属性 [英] How do I hide a property at designtime

查看:85
本文介绍了如何在设计时隐藏属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Olápessoal,



Estou precisando de uma ajuda,Tenho um controle personalizado e gostaria que uma de suas propriedades fosse ocultada caso for selecionado mais de um desse controle em tempo de design。

Olá pessoal,

Estou precisando de uma ajuda, Tenho um controle personalizado e gostaria que uma de suas propriedades fosse ocultada caso for selecionado mais de um desse controle em tempo de design.

Public Class TextBoxEx
    Inherits TextBox
    Public Property MyProperty As String
End Class



假设我在表单中放了两个TextBoxEx。如果我选择TextBoxEx1,MyProperty属性出现在Propertygrid中,但是如果我选择它们就不会出现。



我尝试了什么:



我尝试用ControlDesiger做这个,但我不能,也许是因为缺乏这个类的知识。


Assuming I put two TextBoxEx in my Form. If I select TextBoxEx1 the "MyProperty" property appears in the Propertygrid, but if I select the two it does not appear.

What I have tried:

I tried doing this with ControlDesiger but I could not, maybe because of lack of knowledge of this class.

推荐答案

您可以通过设置其EditorBrowsable属性来隐藏设计时的继承属性:隐藏派生类中的继承属性和任务 [ ^ ] - 显示的代码是C#,但它与VB非常相似:属性概述(Visual Basic)| Microsoft Docs [ ^ ]



但是根据所选项目的数量动态添加或删除项目并不复杂:将MergableProperty属性设置为false 。

MergablePropertyAttribute Class( System.ComponentModel)| Microsoft Docs [ ^ ]
You can hide an inherited property at design time by setting it's EditorBrowsable attribute: Hiding Inherited Properties and Tasks in Derived Classes[^] - the code shown is C#, but it's very similar for VB: Attributes overview (Visual Basic) | Microsoft Docs[^]

But to dynamically add or remove items depending on the number of items selected is no more complicated: set the MergableProperty attribute to false.
MergablePropertyAttribute Class (System.ComponentModel) | Microsoft Docs[^]


这篇关于如何在设计时隐藏属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆