Solved

user control property value

Posted on 2004-08-25
6
212 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
ID: 11892903
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
ID: 11893011
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
ID: 11893300
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
ID: 11893797
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

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

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 …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

896 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

17 Experts available now in Live!

Get 1:1 Help Now