combobox只显示一条logging

我有一个Excel VBA中的combobox,它只显示一个logging,但它应该显示7.我已经debuged的代码,我可以看到程序如何通过代码分配列表中的所有条目,但只有一个显示。

有人能告诉我我错过了什么吗?

SqlSelect = "SELECT distinct [country] FROM [Data]" 'there are 7 records returned in this query Set AdoRst = New ADODB.Recordset AdoRst.Open SqlSelect, WfmDbCn, adOpenForwardOnly, adLockReadOnly, adCmdText With Me.cmbCountry .ColumnCount = 1 .ColumnWidths = "0;0;150" .BoundColumn = 1 Do Until .ListCount = 0 .RemoveItem (0) Loop i = 0 Do While Not AdoRst.EOF .AddItem AdoRst.Fields(0).Value .List(i, 1) = AdoRst.Fields(0) i = i + 1 AdoRst.MoveNext Loop If .ListCount > 0 Then .ListIndex = 0 Else .Value = Null End If End With 

谢谢

问题在于:

 .ColumnCount = 1 .ColumnWidths = "0;0;150" 

你声明只有一列,然后设置3的宽度。如果你适应这样的:

 .ColumnCount = 2 .ColumnWidths = "150;0" 

它应该工作。 这里Boundcolumn并不是真的有用。 .AddItem将值添加到列1; .List(i, 1)将值添加到第2列。