This is a migrated thread and some comments may be shown as answers.

Fixed height radListBox

5 Answers 119 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
FrancoP
Top achievements
Rank 1
FrancoP asked on 12 Nov 2009, 05:15 PM
Good morning.
    I want to programmatically add a fixed height radListBox in the Form_Load. The height should be calculated accordingly to the number of items in the listbox. But the GetItemHeight method returns zero in the Form_Load. If I add a test button, and in the Click event perform the GetItemHeight, the result is 16, ok. Another problem is that I have to add 2 (magic number?) to the total height, otherwise the vertical scrollbar will appear. How can I solve these 2 problems?
 
Thank you

5 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 18 Nov 2009, 01:49 PM
Hi FrancoP,

Thank you for the questions.
 
You can go around the first issue by calculating the height in the Shown event of your form. I am afraid that you will have to make do with the magic number for now. We have plans to improve the virtualization of RadListBox in a future release, which will cause some glitches in the layout to disappear.

Please write again if you have other questions.
 

Best wishes,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
FrancoP
Top achievements
Rank 1
answered on 27 Nov 2009, 04:27 PM
Thank you for your answer, but I can't use the shown event. I have to calculate the height of the item before the listbox be display. Is there a method to do so?
0
Victor
Telerik team
answered on 30 Nov 2009, 11:35 AM
Hello FrancoP,

GetItemHeight() method always returns 16 in the Form load event handler when I am testing it. Are you sure your items are added to the list box? If they are, please post a support ticket and attach a sample application so that I can debug it and provide a direct answer; this could be a potential issue. I am looking forward to your reply.

Kind regards,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
FrancoP
Top achievements
Rank 1
answered on 02 Dec 2009, 02:51 PM

Hello Victor,

I tried with a code like this (VB):

 

Imports Telerik.WinControls.UI

 

Public Class Form1

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim rlb As New RadListBox

 

    Dim rlbi As New RadListBoxItem("Item1")

    rlb.Items.Add(rlbi)

    Dim h As Integer = rlb.GetItemHeight(0)

 

    Controls.Add(rlb)

 

  End Sub

End Class

 

and the value of ‘h’ is 0. If I calculate h after the ‘Controls.Add(rlb)’ I get 16 as expected.

Is there a method to get the item height before adding the radListBox to the controls of the form?

 

Kind regards

0
Victor
Telerik team
answered on 07 Dec 2009, 02:30 PM
Hi FrancoP,

You need to add the RadListBox object to the Controls collection before calling the GetItemHeight() method. Simply move your Controls.Add(rlb) call to just before the Dim h As Integer  = rlb.GetItemHeight(0) statement.
Please write again if you need further assistance.

Best wishes,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
FrancoP
Top achievements
Rank 1
Answers by
Victor
Telerik team
FrancoP
Top achievements
Rank 1
Share this question
or