Category / Section
How to use multiple lines in EditableList?
1 min read
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
Figure 1: Multiple lines used in List item.
Sample Links: