第一次在设计器中设置相关属性的问题

发布于 2024-08-08 18:40:38 字数 306 浏览 8 评论 0原文

我开发了一个表单设计器,还开发了一些继承自标准控件(如按钮)的自定义控件。

另外,我有一些相关的属性,例如用户必须首先选择部门,然后选择人员。在用户选择人员后,我设置自定义控件的文本(在本例中继承自按钮)。
注意:用户可以更改 Text 属性。

一切工作正常,但是当我从数据库加载或拖放控件到表单设计器时,controlName# 设置的文本,

覆盖文本属性并调试它后,我看到文本设置正确,但在设置我的文本后,设计器设置文本controlName#表示这个错误。

如何解决这个问题?

提前致谢
哈米德

I Develop a Form Designer, also develop some custom control that inherit from standard control like button.

Also, i have some property that related, for example user must select department first, and then select person. and after user select person, I set Text of my custom control (that inherit from button in this case).
Note: user can change Text property.

All thing work properly, but when i load from DB or drag and drop control to form designer, Text of controlName# set,

After override Text property and debug it, i see text set right, but after set my text, designer set text with controlName# that this wrong.

How to solve this proplem ?

Thanks in advance
Hamid

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

椵侞 2024-08-15 18:40:38

您可以将一些属性应用于您的属性,例如 ReadOnly,这也将阻止设计者设置您的属性。

我目前找不到链接,但还有一种方法可以告诉表单设计器应该按特定顺序设置属性。


编辑:

好吧,不太像我记忆中的那样,但我认为类似于ISupportInitialize 接口。

像这样:

Public Class Test
    Implements ISupportInitalise

    private _numberOne as integer
    private _numberTwo as integer
    private _initalised as boolean

    Public Property NumberOne() as Integer
        Get
            return _numberOne
        End Get
        Set(value as Integer)

            if _initalised then
                'perform checks here'
            end if

            _numberOne = value 
        End Set
    End Property

    Public Property NumberTwo() as Integer
        Get
            return _numberTwo
        End Get
        Set(value as IntegeR)
            if _initalised then
                'perform checks here'
            end if

            _numberTwo = value 
        End Set
    End Property

    Public Sub BeginInit Implements ISupportInitalise.BeginInit
        _initalised = false
    End Sub

    Public Sub EndInit Implements ISupportInitalise.EndInit
        _initalised = true

        'perform all checks here'
    End Sub

End Class

这样,您的所有检查都可以被禁用,直到您的对象完全初始化为止。

There are attributes you can apply to your properties such as ReadOnly that will stop the designer from setting your property too.

I cant find the link at the moment, but there is also a method of telling the forms designer that it should set properties in a certain order.


Edit:

Ok, not quite what i remembered it as, but i think something like the ISupportInitialize interface.

Something like:

Public Class Test
    Implements ISupportInitalise

    private _numberOne as integer
    private _numberTwo as integer
    private _initalised as boolean

    Public Property NumberOne() as Integer
        Get
            return _numberOne
        End Get
        Set(value as Integer)

            if _initalised then
                'perform checks here'
            end if

            _numberOne = value 
        End Set
    End Property

    Public Property NumberTwo() as Integer
        Get
            return _numberTwo
        End Get
        Set(value as IntegeR)
            if _initalised then
                'perform checks here'
            end if

            _numberTwo = value 
        End Set
    End Property

    Public Sub BeginInit Implements ISupportInitalise.BeginInit
        _initalised = false
    End Sub

    Public Sub EndInit Implements ISupportInitalise.EndInit
        _initalised = true

        'perform all checks here'
    End Sub

End Class

This way all your checking can be disabled until your object is fully initialised.

離殇 2024-08-15 18:40:38

您可以检查覆盖的 Text 设置器是否已设置为 controlName#,如果是,则不执行任何操作。

You could check in your overriden Text setter whether it's being set to controlName# and, if it is, do nothing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文