在vb中设置组合框中的初始值

时间:2012-04-01 10:34:36

标签: vb6 combobox

我有一个从访问数据库填充的组合框。如何添加项目,将“all”添加到从数据库获取的列表中,然后将其显示为第一个值

2 个答案:

答案 0 :(得分:2)

绑定后。你可以安静地做到这一点:

cb.Items.Insert(0,"ALL")

Liked在评论中说。这样做:

Private Sub fview_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
    Timer1.Enabled = True 
    Timer1.Interval = 1000 
    cenNum.DropDownStyle = ComboBoxStyle.DropDownList 
    cenNum.Items.Insert(0, "All") 'adding all to combo  
   fData() 'function populating the combo from database
    cenNum.SelectedIndex=0 'The new line
end sub

答案 1 :(得分:0)

您可以尝试将计算机框的记录来源更改为

 SELECT "All" AS Author_name  FROM Author
 UNION SELECT Author_name FROM Author

例如