How Can I Create A Custom Property Type

Riples

I don't really know how to explain this correctly, so I will try to be as simple as possible.

When you create a Boolean variable (for example) you get a little popup menu allowing you to chose either True or False.

Is there a way of creating a custom property that when referenced, gives a custom list of selectable options?

For example, I want to create a new property called Car_Model that gave users a selectable list of car makes (e.g. Holden, Ford, Chevy, Etc.) So using the property would be something like:

Dim _car as Car = New Car
Car.Car_Model = {Popup a list of selectable options here, e.g. Model.Holden, Model.Ford, Model.Chevy, etc.}
Car.Name = "Betsy"
...

So far I've only really worked with property types within a class, but I guess it's somehow related to creating my own 'Type'. So instead of String or Boolean it would be a Car_Model.

Hope that makes sense. Thanks

Jens

What you want is an Enumeration. You define it like this:

Public Enum CarModel
   BMW = 1
   Porsche = 2
   Audi = 3
   Ferrari = 4
End Enum

You can then define a variable of this type

Dim Model As CarModel = CarModel.Porsche

The enumeration can be understood as named integer variables. So you basically can also assign the respective number to the variable. Assigning values to the enumeration elements is not strictly needed and further properties can be defined using attributes. See MSDN for further details:

http://msdn.microsoft.com/en-us/library/8h84wky1.aspx

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How Can I Create A Custom Property Type

분류에서Dev

How to create element and set custom attribute to map a simple type class property

분류에서Dev

How can I create a re-usable custom HTML panel in ASP.NET MVC?

분류에서Dev

How can I get the type of a Type?

분류에서Dev

How to create an object of class property of type List<class>

분류에서Dev

how can I design custom toast message?

분류에서Dev

What is the (void*) type? And how can I dereference it?

분류에서Dev

How can I create launcher icon for PhpStorm?

분류에서Dev

How can I create multiple SSH keys?

분류에서Dev

How can I create List of rectangles in TypeScript?

분류에서Dev

How can I create A Class with Trait On Scala?

분류에서Dev

How can I create a resource list on Apigility?

분류에서Dev

How can I create dynamic CONTAO pages?

분류에서Dev

How can I get SSRS to create subheadings?

분류에서Dev

How can I create new shell commands?

분류에서Dev

How can I create a footer for cell in datagridview

분류에서Dev

How can I create launcher icon for PhpStorm?

분류에서Dev

how can create specific input type on edittext? The input accettable is Roman numbers M D C X V I

분류에서Dev

Hibernate, how do I get the custom type to register

분류에서Dev

How can I access a class property in an arrow function passed to a constructor?

분류에서Dev

How can I refer to a property of a model within a partial view?

분류에서Dev

How can I have a WiX Property default to null?

분류에서Dev

How can I use a dotted path as a property name of a PropertyChangedEventHandler?

분류에서Dev

For a property found by reflection how can I test for Listness and enumerate over it?

분류에서Dev

Design time serialization of custom type property

분류에서Dev

How to set MSI custom property

분류에서Dev

I can't access property on my object via Expression.Property unless the type of the fed expression is strongly-typed

분류에서Dev

How can I custom my DataTable in React App

분류에서Dev

How can I make a custom "POST" request on client side?

Related 관련 기사

  1. 1

    How Can I Create A Custom Property Type

  2. 2

    How to create element and set custom attribute to map a simple type class property

  3. 3

    How can I create a re-usable custom HTML panel in ASP.NET MVC?

  4. 4

    How can I get the type of a Type?

  5. 5

    How to create an object of class property of type List<class>

  6. 6

    how can I design custom toast message?

  7. 7

    What is the (void*) type? And how can I dereference it?

  8. 8

    How can I create launcher icon for PhpStorm?

  9. 9

    How can I create multiple SSH keys?

  10. 10

    How can I create List of rectangles in TypeScript?

  11. 11

    How can I create A Class with Trait On Scala?

  12. 12

    How can I create a resource list on Apigility?

  13. 13

    How can I create dynamic CONTAO pages?

  14. 14

    How can I get SSRS to create subheadings?

  15. 15

    How can I create new shell commands?

  16. 16

    How can I create a footer for cell in datagridview

  17. 17

    How can I create launcher icon for PhpStorm?

  18. 18

    how can create specific input type on edittext? The input accettable is Roman numbers M D C X V I

  19. 19

    Hibernate, how do I get the custom type to register

  20. 20

    How can I access a class property in an arrow function passed to a constructor?

  21. 21

    How can I refer to a property of a model within a partial view?

  22. 22

    How can I have a WiX Property default to null?

  23. 23

    How can I use a dotted path as a property name of a PropertyChangedEventHandler?

  24. 24

    For a property found by reflection how can I test for Listness and enumerate over it?

  25. 25

    Design time serialization of custom type property

  26. 26

    How to set MSI custom property

  27. 27

    I can't access property on my object via Expression.Property unless the type of the fed expression is strongly-typed

  28. 28

    How can I custom my DataTable in React App

  29. 29

    How can I make a custom "POST" request on client side?

뜨겁다태그

보관