We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the item height based on number of lines in WinForms EditableList?

Platform: WinForms |
Control: EditableList
Tags: windowsform

Customize the item height

In EditableList, it is possible to specify its item height with respect to its Text length, by handling its events named MeasureItem and DrawItem.




This event helps to customize the Item height.




This event helps to customize the Item content appearance.


Following code example demonstrates the same.


//Customize the Visibility of Items.
void ListBox_DrawItem(object sender, DrawItemEventArgs e)
   if (e.Index >= 0)
       e.Graphics.DrawString(item[e.Index], new Font(FontFamily.GenericSansSerif, 14, FontStyle.Bold), new SolidBrush(color[e.Index]), e.Bounds);
//Determines the Size of the Item.
void ListBox_MeasureItem(object sender, MeasureItemEventArgs e)
   //Numlines is total number of lines in a text
   e.ItemHeight = 25*numLines;



'Customize the Visibility of Items.
Private Sub ListBox_DrawItem(sender As Object, e As DrawItemEventArgs)
    If e.Index >= 0 Then
       e.Graphics.DrawString(item(e.Index), New Font(FontFamily.GenericSansSerif, 14, FontStyle.Bold), New SolidBrush(color(e.Index)), e.Bounds)
    End If
End Sub
'Determines the Size of the Item.
Private Sub ListBox_MeasureItem(sender As Object, e As MeasureItemEventArgs)
    'Numlines is total number of lines in a text
    e.ItemHeight = 25 * numLines
End Sub


           Item height based on list of items in EditableList

Figure 1. Item Height based on List of Items in EditableList with Image.



C#: Determine Item Height Based on number of Item Lines C#

VB: Determine Item Height Based on number of Item Lines VB



2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile