开发者

Problem with set related property in designer at first time

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 de开发者_StackOverflow社区partment 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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜