Word wrap while entering text.

Posted by: sathish-k on 8 September 2017, 2:23 pm EST

  • Posted 8 September 2017, 2:23 pm EST

    hi i m using farpoint 2.5.1003.2002. just like excel i need word wrap in farpoint. how can i achive this farpoint.
  • Replied 8 September 2017, 2:23 pm EST

    Hello Sathish,


    You can assign a TextCellType to Spread's cell having wordwrap property set to true:-



     FarPoint.Win.Spread.CellType.TextCellType txt = new FarPoint.Win.Spread.CellType.TextCellType();
     txt.WordWrap = true;
     fpSpread1.Sheets[0].Cells[0, 0].CellType = txt;
     fpSpread1.Sheets[0].Cells[0, 0].Text = "This is a multiline text cell type having longgg text in a single cell.";
     fpSpread1.ActiveSheet.Rows[0].Height = 100;


    Thanks.

  • Replied 8 September 2017, 2:23 pm EST

    hi reeva,


          thanks for your  reply.  but my requirement is row height is to be changed dynamically bcoz user will enter the text in that cell for more than 1000 characters according to that row height to be changed(give wrap text in excel for cell and see how it works same is my reqirement).

  • Replied 8 September 2017, 2:23 pm EST

    Hello Sathish,


    For setting the RowHeight dynamically, you need to use the GetPrefferedHeight method in LeaveCell event to set the height of the row. Here is the code to achieve the same:-



           private void Form1_Load(object sender, EventArgs e)
            {
                FarPoint.Win.Spread.CellType.TextCellType txt = new FarPoint.Win.Spread.CellType.TextCellType();
                txt.WordWrap = true;
                fpSpread1.Sheets[0].Cells[0, 0].CellType = txt;
                fpSpread1.Sheets[0].Cells[0, 0].Text = "This is a multiline text cell type having longgg text in a single cell.";
                fpSpread1.ActiveSheet.Rows[0].Height = fpSpread1.ActiveSheet.Rows[0].GetPreferredHeight();
                fpSpread1.LeaveCell += new FarPoint.Win.Spread.LeaveCellEventHandler(fpSpread1_LeaveCell);
            }
             void fpSpread1_LeaveCell(object sender, FarPoint.Win.Spread.LeaveCellEventArgs e)
            {
                fpSpread1.ActiveSheet.Rows[e.Row].Height = fpSpread1.ActiveSheet.Rows[0].GetPreferredHeight();
            }


    Hope this will help you. Let us know in case you need some more clarification. Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels