locked
Number of items in a listbox RRS feed

  • Question

  • Hi all, I have the following question: 
    How I can limit the number of rows in a listbox? 
    Greetings
    Thursday, October 16, 2014 9:59 PM

Answers

  • I assume that you have code to let the end users add items to the list box. You can check ListCount in this code and refuse to add an item if there are already 10 items.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by aslf010990 Friday, October 17, 2014 2:15 PM
    Friday, October 17, 2014 12:42 AM
  • in add event you can to write

              if (listBoxControl1.ItemCount < 10)
                    listBoxControl1.Items.Add( Object You Want To Add );

    • Marked as answer by aslf010990 Friday, October 17, 2014 2:15 PM
    Friday, October 17, 2014 1:04 AM

All replies

  • The ListCount property of a list box returns the number of items in the list. For example:

    Debug.Print ListBox1.ListCount

    will return the number of items in a list box named ListBox1 to the Immediate window.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Thursday, October 16, 2014 10:23 PM
  • ok, but what I want to know is how to limit the number of items in the listbox, such that its maximum size is 10 lines, greetings
    Thursday, October 16, 2014 10:28 PM
  • I assume that you have code to let the end users add items to the list box. You can check ListCount in this code and refuse to add an item if there are already 10 items.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by aslf010990 Friday, October 17, 2014 2:15 PM
    Friday, October 17, 2014 12:42 AM
  • in add event you can to write

              if (listBoxControl1.ItemCount < 10)
                    listBoxControl1.Items.Add( Object You Want To Add );

    • Marked as answer by aslf010990 Friday, October 17, 2014 2:15 PM
    Friday, October 17, 2014 1:04 AM
  • ok , thanks
    Friday, October 17, 2014 2:17 PM
  • ok , thanks
    Friday, October 17, 2014 2:17 PM