Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Displaying property values in IDE

Posted on 2004-09-19
6
Medium Priority
?
243 Views
Last Modified: 2010-04-23
Hi there.

I am creating an inherited control containing a property named InputDataType which denotes what type of data the user will by allowed to type in. However, I want this property to have the predefined "String","Integer","Decimal" values in the IDE, thing which doesn't happen with the string type (happens with types such as boolean that have predefined values). I suppose I have to create a class, array, collection or something but I have been unable to find how to do it. Here is my code:

Private strInputDataType As String = "String"

Public Property InputDataType() As String
Get
Return strInputDataType
End Get
Set(ByVal Value As String)
Select Case Value
Case "String", "Integer", "Decimal"
strInputDataType = Value
Case Else
strInputDataType = "String"
End Select
End Set
End Property

What must I do in order for the "String", "Integer" and "Decimal" values to be displayed in the IDE in the property's value field?

Thanks...
0
Comment
Question by:acicovic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
vigrid earned 400 total points
ID: 12096416
Simple. Use enumerations

Enum DataType
  String,
  Integer,
  Decimal
End Enum

And use DataType enumeration in place of your strings. You should have access to the type in the designer in a way you wanted.

HTH
0
 
LVL 2

Author Comment

by:acicovic
ID: 12096774
Hi there.

I tried, but I don't seem to be able to achieve it.  The only change is that I have to type 0 (for str), 1 (for int) and 2 (for dec) (which should be the inverse if I want it to be user friendly).  In addition, the numbers do *not* appear in a list.  My code:

    Enum DataType
        Str = 0
        Int = 1
        Dec = 2
    End Enum

    Public Property InputDataType() As DataType
        Get
            Return strInputDataType
        End Get
        Set(ByVal Value As DataType)
            Select Case Value
                Case DataType.Str, DataType.Int, DataType.Dec
                    strInputDataType = Value
                Case Else
                    strInputDataType = DataType.Str
            End Select
        End Set
    End Property

What am I doing wrong?
0
 
LVL 2

Author Comment

by:acicovic
ID: 12096781
forgot to mention that below the Enum I have the following line:

Private strInputDataType As DataType
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Expert Comment

by:vigrid
ID: 12096986
Public Class UserControl1
      Inherits UserControl

      ' Methods
      Public Sub New()
      Protected Overrides Sub Dispose(ByVal disposing As Boolean)
      Private Sub InitializeComponent()

      ' Properties
      Public Property InputDataType As DataType

      ' Fields
      Private components As Container
      Private m_type As DataType

      ' Nested Types
      Public Enum DataType
            ' Fields
            [Decimal] = 1
            [Integer] = 0
            [String] = 2
      End Enum

      Public Property InputDataType As DataType
            Get
                  Return Me.m_type
            End Get
            Set(ByVal value As DataType)
                  Me.m_type = value
            End Set
      End Property
End Class

0
 
LVL 4

Expert Comment

by:vigrid
ID: 12096993
Very fast example. I made it in C#, compiled it and decompiled it in .NET Reflector, so the code may seem funny at first look, but the essential functionality is there. I don't know VB.NET, so I'm helping you out with my C# experience. HTH
0
 
LVL 2

Author Comment

by:acicovic
ID: 12105705
Hi there.

I Got it working, although I cannot understand why it didn't work in the first place.  Here's the code for anyone who's interested:

    Enum DataType As Byte
        [Decimal]
        [Integer]
        [String]
    End Enum

    Private dtInputDataType As DataType

    Public Property InputDataType() As DataType
        Get
            Return dtInputDataType
        End Get
        Set(ByVal Value As DataType)
            Select Case Value
                Case DataType.String, DataType.Integer, DataType.Decimal
                    dtInputDataType = Value
                Case Else
                    dtInputDataType = DataType.String
            End Select
        End Set
    End Property
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question