view raw
Dhairya Joshi Dhairya Joshi - 7 months ago 26 Question

Auto Fill combo box is taking full page of size when we press drop down. Need to limit it to top 5 values. without doing query change

I need a little help here with auto fill combo box which will display all the vehicles which are owned by Company.
Please check the screen shot and code and guide me to how to limit the display items in number of 5 so that combo box does not take the full size of page.
I don't want to change anything in query, i want to set it from the code or any available property which can limit it (Note : MaximumDropDownItems is already at 8 still it takes full page). The drop down menu must drop on bottom of the combo box not on upper side of it.


Screen Shot

enter image description here

The code for auto fill is as follow :

Dim v As New VehicleMast
dt = v.getvhcl("select Vehicle_NO from MastVehicle")

If com_vhcl_no.InvokeRequired Then
com_vhcl_no.BeginInvoke(New loadVehicleDel(AddressOf loadVehicleSub), cmd, dt)
For Each q In dt.Rows

With com_vhcl_no
'.DataSource = dt
.DisplayMember = "Vehicle_NO"
.ValueMember = "Vehicle_NO"
.AutoCompleteMode = AutoCompleteMode.Suggest
.AutoCompleteSource = AutoCompleteSource.ListItems
End With

End If


You can probably set the height of the ComboBox which can show only a few records and else all the records would be scroll-able


you can make 5 items visible for all of the items, by doing something like this:

ComboBox1.DropDownList.Height = ComboBox1.Items.Height * 5


ComboBox1.MaxDropDownItems = 5;