Do you have a Property Let and Property Get for this your property?
In the Property Let you should do a PropertyChanged "name" for your property, you can then call this Property Let to change this property.
Printable View
Do you have a Property Let and Property Get for this your property?
In the Property Let you should do a PropertyChanged "name" for your property, you can then call this Property Let to change this property.
Yes,I do.
Thank you very much!
Maybe I didn't express my problem clearly last time.You know,if a property is defined as Enum type, in design time we can set its value by selecting from a list containing a series of fixed values through the property browser.
Otherwise the DataField property of a TextBox is different from above.Its value list is not fixed but alterative if the DataSourse is changed.Distinctly during development of the TextBox Control the DataField is not defined as Enum type.
How can I make a UserControl's property to have these design-time actions as the DataField.
Thanks again for your reply!
I have a TextBox with a DataType property, you enter a number and this is replaced with text to show what that the datatype is.
Here's the code, I'm not sure if it's the kind of thing you want or not:VB Code:
Public Property Get DataType() As Variant '****************************************************************************** '* Purpose : Returns the datatype of the text box contents '* '* Parameters : None '* '* Return : None '****************************************************************************** 'design time function Select Case m_intDataType Case vbInteger DataType = CStr(vbInteger) & " - vbInteger" Case vbLong DataType = CStr(vbLong) & " - vbLong" Case vbSingle DataType = CStr(vbSingle) & " - vbSingle" Case vbDouble DataType = CStr(vbDouble) & " - vbDouble" Case vbCurrency DataType = CStr(vbCurrency) & " - vbCurrency" Case vbString DataType = CStr(vbString) & " - vbString" Case vbObject DataType = CStr(vbObject) & " - vbObject" Case vbError DataType = CStr(vbError) & " - vbError" Case vbBoolean DataType = CStr(vbBoolean) & " - vbBoolean" Case vbVariant DataType = CStr(vbVariant) & " - vbVariant" Case vbDataObject DataType = CStr(vbDataObject) & " - vbDataObject" Case vbDecimal DataType = CStr(vbDecimal) & " - vbDecimal" Case vbByte DataType = CStr(vbByte) & " - vbByte" Case vbArray DataType = CStr(vbArray) & " - vbArray" Case Else End Select End Property Public Property Let DataType(ByVal i_vntDataType As Variant) '****************************************************************************** '* Purpose : Sets the datatype of the text box '* '* Parameters : i_vntDataType '* '* Return : None '****************************************************************************** m_intDataType = CInt(i_vntDataType) PropertyChanged "DataType" AlignTextBox End Property
If I understood the problem, then it has no solution. Atleast to my knowledge.
Now if you want to make a property databound, thats easy. VB will automatically add the DataSource, DataMember and DataField properties to your control. But is that what you want?
No, I don't want to bind a control to a DataSource, or it is easy.
I tend to create one property which is similar with the DataField,but it does not belong to DataBinding,it is to say,in design time this property's value can be set by selecting one item from a list.although the list can be shown in the property browser,but it is not based on a Enum datatype.
It really has no solution?
Thank you very much foy the reply!
I don't know if you would like it. But there is no way you can tell vb about the list to be displayed in the properties window.
There is a work around. Use a property page and use a combo box on it with the drop down list box style. Associate the property page with that particular property.
Now when the property page is displayed, populate the combo box depending on the selections of the other property, the user may then click on the elipsis in the property browser, then select the appropriate value from the property page.
Does it look complicated?
It took a long time for me to find this way around.
Thank you, Abu Haider, you're surely a kind one.
The way you told me is proved to be a successful solution by me before.It seems to have no more effective way to solve the problem.
thanks again.