Click to See Complete Forum and Search --> : About usercontrol's property design
Bonker Gudd
Oct 9th, 2001, 05:21 AM
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.
Q.Jimmy
Oct 9th, 2001, 08:45 PM
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!
Bonker Gudd
Oct 10th, 2001, 03:18 AM
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:
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
Abu haider
Oct 11th, 2001, 08:43 AM
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?
Q.Jimmy
Oct 11th, 2001, 08:15 PM
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!
Abu haider
Oct 12th, 2001, 11:49 AM
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.
Q.Jimmy
Oct 15th, 2001, 12:56 AM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.