Solved

user control property value

Posted on 2004-08-25
6
201 Views
Last Modified: 2010-04-23
Hi experts ,
I am creating a user control , this control has a combobox , this combo box will display a lookup field in the database , the user control will has a set of properties that I will add , like db_type,db_name ,table _name , field_name . The property of db_type will has  list of values (Access,SqlServer,Oracle) . I do tis property with this code :

    Public Enum en
        Access
        SqlServer
        Oracle
    End Enum

    ReadOnly Property db_type() As en
        Get
        End Get
    End Property

so I give the db_type property the type of en.
 
the problem now , I want to write another property which is field_name which will also display a list of field names depends on the table_name . But I do not know what is the type of the property field_name , because it will have a list of data . and I can not use the enum , because it is a constant type . And the field list is dynamic depending on the table_name property.

0
Comment
Question by:Hamdan
  • 3
6 Comments
 
LVL 25

Expert Comment

by:RonaldBiemans
Comment Utility
maybe an array of strings

    Public Property field_names() As String()
        Get

        End Get
        Set(ByVal Value As String())

        End Set
    End Property

0
 
LVL 25

Expert Comment

by:RonaldBiemans
Comment Utility
or maybe

    Dim _datacol As DataColumnCollection
    Dim _tbl As DataTable

    Public Property tbl() As DataTable
        Get
            Return _tbl
        End Get
        Set(ByVal Value As DataTable)
            _tbl = Value
            datacol = _tbl.Columns
        End Set
    End Property

    Public Property datacol() As DataColumnCollection
        Get
            Return _datacol
        End Get
        Set(ByVal Value As DataColumnCollection)
            _datacol = Value
        End Set
    End Property
0
 

Author Comment

by:Hamdan
Comment Utility
No no , nothing of this code will give me a property with list of values . Array and collection types will not make the value of the propery as list !
0
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 500 total points
Comment Utility
Ok, I understand what you mean, so what you really want is to dynamically build an enum type.
This is possible but not simple you have to use the enumbuilder class in
system.reflection.emit.enumbuilder, look here for an example

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemreflectionemitenumbuilderclasstopic.asp
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

16 Experts available now in Live!

Get 1:1 Help Now