Solved

Displaying property values in IDE

Posted on 2004-09-19
6
203 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
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
vigrid earned 100 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now