Results 1 to 7 of 7

Thread: About usercontrol's property design

  1. #1

    Thread Starter
    Fanatic Member Bonker Gudd's Avatar
    Join Date
    Mar 2000
    Location
    Saturn
    Posts
    748
    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.

  2. #2
    Junior Member
    Join Date
    Sep 2001
    Posts
    19
    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!

  3. #3

    Thread Starter
    Fanatic Member Bonker Gudd's Avatar
    Join Date
    Mar 2000
    Location
    Saturn
    Posts
    748

    Well ...

    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:
    1. Public Property Get DataType() As Variant
    2.    '******************************************************************************
    3. '*  Purpose :       Returns the datatype of the text box contents
    4. '*
    5. '*  Parameters :    None
    6. '*
    7. '*  Return :        None
    8. '******************************************************************************
    9.  
    10.     'design time function
    11.     Select Case m_intDataType
    12.         Case vbInteger
    13.             DataType = CStr(vbInteger) & " - vbInteger"
    14.         Case vbLong
    15.             DataType = CStr(vbLong) & " - vbLong"
    16.         Case vbSingle
    17.             DataType = CStr(vbSingle) & " - vbSingle"
    18.         Case vbDouble
    19.             DataType = CStr(vbDouble) & " - vbDouble"
    20.         Case vbCurrency
    21.             DataType = CStr(vbCurrency) & " - vbCurrency"
    22.         Case vbString
    23.             DataType = CStr(vbString) & " - vbString"
    24.         Case vbObject
    25.             DataType = CStr(vbObject) & " - vbObject"
    26.         Case vbError
    27.             DataType = CStr(vbError) & " - vbError"
    28.         Case vbBoolean
    29.             DataType = CStr(vbBoolean) & " - vbBoolean"
    30.         Case vbVariant
    31.             DataType = CStr(vbVariant) & " - vbVariant"
    32.         Case vbDataObject
    33.             DataType = CStr(vbDataObject) & " - vbDataObject"
    34.         Case vbDecimal
    35.             DataType = CStr(vbDecimal) & " - vbDecimal"
    36.         Case vbByte
    37.             DataType = CStr(vbByte) & " - vbByte"
    38.         Case vbArray
    39.             DataType = CStr(vbArray) & " - vbArray"
    40.         Case Else
    41.            
    42.     End Select
    43.  
    44. End Property
    45.  
    46. Public Property Let DataType(ByVal i_vntDataType As Variant)
    47. '******************************************************************************
    48. '*  Purpose :       Sets the datatype of the text box
    49. '*
    50. '*  Parameters :    i_vntDataType
    51. '*
    52. '*  Return :        None
    53. '******************************************************************************
    54.     m_intDataType = CInt(i_vntDataType)
    55.     PropertyChanged "DataType"
    56.     AlignTextBox
    57. End Property

  4. #4
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Orlando
    Posts
    392
    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?
    Abu Haider
    ____________________________
    100% Data Validation for the MS DataGrid Control. Plus Support for Custom and Foreign Lists, DatePicker and much more...
    The DataGridEnhancer


    I often point to a place where the problem has been discussed, instead of giving you the code that solves it. This is for good, may be you will understand some day...

  5. #5
    Junior Member
    Join Date
    Sep 2001
    Posts
    19
    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!

  6. #6
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Orlando
    Posts
    392
    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.
    Abu Haider
    ____________________________
    100% Data Validation for the MS DataGrid Control. Plus Support for Custom and Foreign Lists, DatePicker and much more...
    The DataGridEnhancer


    I often point to a place where the problem has been discussed, instead of giving you the code that solves it. This is for good, may be you will understand some day...

  7. #7
    Junior Member
    Join Date
    Sep 2001
    Posts
    19
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width