During my development progress i was stuck up with a problem.
I used a class MyList and with the Help of this MyList the combo box named cboCity was filled with City Code(like 1001,1002,etc..) as Value member and City Name (like Canada,California etc...) as display member.
Public Class MyList Private _dispName As String Private _valMember As Integer Public Sub New() _dispName = "" _valMember = 0 End Sub Public Sub New(ByVal dispName As String, ByVal valMember As Integer) _dispName = dispName _valMember = valMember End Sub Public Property DisplayName() As String Get Return _dispName End Get Set(ByVal value As String) _dispName = value End Set End Property Public Property ValueMember() As Integer Get Return _valMember End Get Set(ByVal value As Integer) _valMember = value End Set End Property Public Overrides Function ToString() As String Return _dispName End Function End Class
Dim _MyList as MyList _MyList = New MyList("Canada",1001) _MyList = New MyList("California",1002) _MyList = New MyList("Sydney",1003) _MyList = New MyList("Melbourne",1004) cbo.Items.Add(_MyList)
The value members 1001,1002,1003,1004 get inserted as per cbocity(combo box)display name selection , into the database and during the retrieval of the record the value member is obtained and based on that for eg:when i get 1001 the selected item should be Canada.I tried many ways while fetching the record and set the selected item but all fails . Please kindly help me in providing the solution.