How can I get the number of items listed in a combobox?
setModel(ComboBoxModel a) : sets the data model that the JComboBox uses to obtain the list of items. setMaximumRowCount(int count): sets the maximum number of rows the JComboBox displays.
To add a set of items to the combo box it is best to use the AddRange method. If you choose to use the Add method to add a number of items to the combo box, use the BeginUpdate method to suspend repainting during your add and the EndUpdate method to resume repainting.
Try
var count = comboBox.Items.Count;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With