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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use multiple lines in EditableList?

Platform: WinForms |
Control: EditableList |
Published Date: January 28, 2016 |
Last Revised Date: May 24, 2019

In EditableList, multiple lines of text can be displayed by using new line indicator “\n” in the List item text and adjusting list item height, using its property named ItemHeight.

 

The following code example demonstrates the same.

C#

//To specify the list item height.
this.editableList1.ListBox.ItemHeight = 50;
//To add the list item.
this.editableList1.ListBox.Items.Add("Name: Mercury\nMass: 0.055 Earths\nYear: 87.9691 Earth days\nTemp: 183 °C to 427 °C");
this.editableList1.ListBox.Items.Add("Name: Venus\nMass: 0.815 Earths\nYear: 243 Earth days");
this.editableList1.ListBox.Items.Add("Name: Earth\nMass: 1.0 Earths\nYear: 365.256 Earth days");
this.editableList1.ListBox.Items.Add("Name: Mars\nMass: 0.107 Earths\nYear: 686.971 Earth days");
//Occurs before the item editing
this.editableList1.BeforeListItemEdit += new CancelEventHandler(editableList1_BeforeListItemEdit);
 
void editableList1_BeforeListItemEdit(object sender, CancelEventArgs e)
{
    //To cancel the editing operation.
    e.Cancel = true;
}

 

VB

'To specify the list item height.
Me.editableList1.ListBox.ItemHeight = 50
'To add the list item.
Me.editableList1.ListBox.Items.Add("Name: Mercury" & Constants.vbLf & "Mass: 0.055 Earths" & Constants.vbLf & "Year: 87.9691 Earth days" & Constants.vbLf & "Temp: 183 °C to 427 °C")
Me.editableList1.ListBox.Items.Add("Name: Venus" & Constants.vbLf & "Mass: 0.815 Earths" & Constants.vbLf & "Year: 243 Earth days")
Me.editableList1.ListBox.Items.Add("Name: Earth" & Constants.vbLf & "Mass: 1.0 Earths" & Constants.vbLf & "Year: 365.256 Earth days")
Me.editableList1.ListBox.Items.Add("Name: Mars" & Constants.vbLf & "Mass: 0.107 Earths" & Constants.vbLf & "Year: 686.971 Earth days")
'Occurs before the item editing
AddHandler editableList1.BeforeListItemEdit, AddressOf editableList1_BeforeListItemEdit
 
Private Sub editableList1_BeforeListItemEdit(ByVal sender As Object, ByVal e As CancelEventArgs)
 'To cancel the editing operation.
 e.Cancel = True
End Sub

 

Showing multiple lines used in list item

Figure 1: Multiple lines used in List item.

 

Sample Links:

C#: EditableList_MultiLine_C#

VB: EditableList_MultiLine_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
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.

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