views:

47

answers:

2

Hi

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

A: 

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

SLaks
+1  A: 

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.

Pondidum
I can't set Readonly attribute, because user can change it, butExact i need this: "method of telling the forms designer that it should set properties in a certain order". Could you please find link? (also i will do) MANY THANKS
Hamid
It might not have been a web page now that i think about it, it could have been in one of my books.
Pondidum
Ok, I'm pretty sure its in a book, I will update when I get home and can have a look in the book.
Pondidum
THANKS A LOT, very nice
Hamid