Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the exact height of a listbox in Windows Forms (C#)?

I've been having some difficulties with setting the height of a listbox.

Code like this...

listbox1.Height = some_number;

... works only for some numbers. It seems that height of listbox may be only multiplication of height of its element. Is there a way how to "override" this behaviour?

like image 343
Martin Vseticka Avatar asked Aug 31 '09 15:08

Martin Vseticka


People also ask

How do I set the size of a ListBox?

Step 2: Drag the ListBox control from the ToolBox and drop it on the windows form. You are allowed to place a ListBox control anywhere on the windows form according to your need. Step 3: After drag and drop you will go to the properties of the ListBox control to set the size of the ListBox.

What is integral height?

The integral height is based on the height of the ListBox, rather than the client area height. As a result, when the IntegralHeight property is set true , items can still be partially shown if scroll bars are displayed.

What method can we use to add the items into the ListBox?

To insert an item into the list box at a specific position, use the Insert method. To add a set of items to the list box in a single operation, use the AddRange method.


1 Answers

Try,

listbox1.IntegralHeight=false;
listbox1.Height=some_int_number;
like image 56
KV Prajapati Avatar answered Sep 18 '22 18:09

KV Prajapati