FlexSheet for WPF | ComponentOne
Customizing Appearance / Customizing Cells / Cell Formatting / Wrap Text
In This Topic
    Wrap Text
    In This Topic

    Text wrapping can be done when there is too much data to be displayed in a single cell. Wrapping cell data gives you an advantage to display large amount of data in multiple lines in a single cell.

    You might find text wrapping useful where you need to write long strings in a cell. For example, you need to create a list of vendors with all the details regarding products they supply, including their address details. Address can be lengthy so wrapping text can help in writing multiple lines of address in a single cell. The TextWrapping field of CellFormat enum can be used to wrap the text.

    Perform the given steps to wrap text in a cell in C1FlexSheet:

    1. Add a CheckBox in your application to wrap text in a cell.
    2. Add the following code to the Checked event of the CheckBox:
      Dim cellRange = flex.Selection.Cells
      flex.SetCellFormat(cellRange, CellFormat.TextWrapping, chkWrapText.IsChecked)
      
      flex.Invalidate()
      
      var cellRange = flex.Selection.Cells;
      flex.SetCellFormat(cellRange, CellFormat.TextWrapping, chkWrapText.IsChecked);
      
      flex.Invalidate();
      

      This code wraps the text once the Wrap Text checkbox is checked and the output looks similar to the following image:

      Wrapping Text

      To unwrap text in a cell, click Wrap Text check box again. Add the following code to the Unchecked event of the CheckBox:

      Dim cellRange = flex.Selection.Cells
      flex.SetCellFormat(cellRange, CellFormat.TextWrapping, chkWrapText.IsChecked)
      flex.Invalidate()
      
      var cellRange = flex.Selection.Cells;
      flex.SetCellFormat(cellRange, CellFormat.TextWrapping, chkWrapText.IsChecked);
      flex.Invalidate();