Hi I used below code for filling my combo box with a dataset, but when I want to set this combo box with new dataset in the second time I got this error
"Cant modify the items collection when the datasource property is set."
how can I release my combo box from previous datasource to setting new datasource?
please help me
thanks
P.S. this is my code:
"Cant modify the items collection when the datasource property is set."
how can I release my combo box from previous datasource to setting new datasource?
please help me
thanks
P.S. this is my code:
Code:
Public Sub DoFillComboWithValues(ByRef MyComboBox As ComboBox, ByVal strStoredProcedureName As String, ByVal shoTableID As Short, ByVal strValueMember As String, ByVal strDisplayMember As String)
Dim ds As DataSet = SqlHelper.ExecuteDataset(g_strConnection, CommandType.StoredProcedure, strStoredProcedureName, New SqlParameter("@TableID", shoTableID))
Dim dtBasicValues As DataTable = ds.Tables(0)
Dim dvBasicValues As DataView = dtBasicValues.DefaultView
dvBasicValues.Sort = "Basic_Default"
Dim foundIndex As Integer = dvBasicValues.Find(1)
With MyComboBox
.Items.Clear()
.ValueMember = strValueMember
.DisplayMember = strDisplayMember
.DataSource = dvBasicValues
End With
End Sub
Last edited by a moderator: