Hi all,
.Net: v1.1
Software: Visual Studio 2003
I have a usercontrol that dynamically creates a combobox control and alligns it on the usercontrol. Now I want to add a property to the usercontrol to assign a default value to this combobox.
I already have properties for datasource, displaymember and valuemember and the combobox loads it's data just fine.
So what I do to get the defaultvalue to work is this:
This usercontrol variable mstrDefaultComboValue is also used for this piece of code in the UserControl_Load event:
Now I don't know why but for some reason this combo doesn't load it's Items collection even though the datasource is loaded!
So my question to you is, on which event does the combobox load the Items collection from what is in the DataSource of the combo?
Thanks a lot!
.Net: v1.1
Software: Visual Studio 2003
I have a usercontrol that dynamically creates a combobox control and alligns it on the usercontrol. Now I want to add a property to the usercontrol to assign a default value to this combobox.
I already have properties for datasource, displaymember and valuemember and the combobox loads it's data just fine.
So what I do to get the defaultvalue to work is this:
VB.NET:
Public Property ComboSelectedValue() As Object
Get
If Not cboCombo Is Nothing Then Return cboCombo.SelectedValue
End Get
Set(ByVal Value As Object)
If Not cboCombo Is Nothing Then
cboCombo.Update()
cboCombo.Refresh()
cboCombo.SelectedValue = Value
mstrDefaultComboValue = CString(Value)
End If
End Set
End Property
VB.NET:
If Not cboCombo Is Nothing Then
With cboCombo
.Top = btnAdd.Top
.Left = 8
.Width = Me.grpMain.Width - btnAdd.Width - 16
.DropDownWidth = Me.grpMain.Width - btnAdd.Width - 16
.DropDownStyle = ComboBoxStyle.DropDownList
.SelectedValue = mstrDefaultComboValue
End With
End If
Now I don't know why but for some reason this combo doesn't load it's Items collection even though the datasource is loaded!
So my question to you is, on which event does the combobox load the Items collection from what is in the DataSource of the combo?
Thanks a lot!