Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am customizing controls in Vb.net. Usual way of property declaration is OK. But I want to declare property where I will choose any of the two options of a property and accordingly continue other processes. As for example I want to declare a property name ChooseProcessOption(OneWay/TwoWay) as list. User will choose any of the option. I tried the following way, but not error and not working. Please help me as I am stuck here. Thanks a lot.

What I have tried:

Dim dataSourceOption() As String


    Public Sub New()

        ReDim dataSourceOption(1)
        dataSourceOption(0) = "Procedure"
        dataSourceOption(1) = "Table/View Using SQL"


    End Sub
    Property ShahDataSourceOption(index As Integer) As String
        Get
            Return dataSourceOption(index)
        End Get
        Set(value As String)
            dataSourceOption(index) = value
        End Set
    End Property
Posted
Updated 14-Feb-21 6:48am

1 solution

What about this :
VB
<Flags()>
Enum selection As Integer
    option1 = 1
    option2 = 2
    option3 = 4
    option4 = 8
End Enum

Property mySelection As selection
    Get
        Return _mySelection
    End Get
    Set(value As selection)
        _mySelection = value
    End Set
End Property
Private _mySelection As selection = selection.option1
 
Share this answer
 
Comments
Maciej Los 14-Feb-21 7:40am    
5ed!
Ralf Meier 17-Feb-21 4:11am    
Thank you Maciej ...
Shah Samiur Rashid 14-Feb-21 13:16pm    
I never used enum. It works great. Thanks a lot Mr Ralf.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900