Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / How to simulate the ALT-ENTER in excel when adding data

How to simulate the ALT-ENTER in excel when adding data

New Discussion
Maya Kirova
Maya Kirova asked on May 22, 2012 4:03 PM

I am creating an Worksheet and attempting to add data to a cell.  I want to pass what Excel uses as alt enter (chr(10)) so that my data shows up as multiple lines within a single cell.  How can this be done?

Sign In to post a reply

Replies

  • 0
    Maya Kirova
    Maya Kirova answered on May 22, 2012 2:39 PM

    Hello,

    The new line that get created when you use alt+enter is actually a “/r/n” string when represented as a cell value. So to add such value you just need to add “/r/n” where you need the new line in the cell. So for example:

    cell2.Value = "Sample Text , Sample Text \r\n \r\n \r\n Some more text \r\n Custom text";

    Would generate a text in a cell with new lines. Also keep in mind that the WrapText property needs to be set to true:

    cell2.CellFormat.WrapText = ExcelDefaultableBoolean.True;

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer

    Infragistics, Inc.

    http://pt-br.infragistics.com/support

    • 0
      Mike Dour
      Mike Dour answered on May 22, 2012 4:03 PM

      FYI, due to a fix for issue 103739 in the latest SR of versions 11.1 and later, the cell's WrapText value will be automatically set to True when it is Default and text with newlines is set on the cell. This is mimic how MS Excel automatically turns on wrap text for a cell when Alt+Enter is used to add newlines in that cell.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Maya Kirova
Favorites
0
Replies
2
Created On
May 22, 2012
Last Post
13 years, 9 months ago

Suggested Discussions

Created by

Created on

May 22, 2012 4:03 PM

Last activity on

Feb 12, 2026 4:16 PM