Enter = New Line in MultiLine Text Cell

7 posts, 1 answers
  1. Crane101
    Crane101 avatar
    2 posts
    Member since:
    Jul 2010

    Posted 05 Sep 2011 Link to this post

    Can't seem to find an answer that works on the forums anywhere for this one.

    When I press enter when in edit mode on a text cell, I want to insert a new line rather than ending the cell edit, but no combination of catching key presses or any other grid or cell events seems to be able to achieve this.

    Any help with this would be greatly appreciated.

    Shane

  2. Answer
    Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 08 Sep 2011 Link to this post

    Hello Shane,

    Thank you for your question. The AcceptsReturn property of GridViewTextBoxColumn defines how the editor handles Enter key - end edit ('false', default value) or create new line.

    If you have further questions, we will be glad to help.

    Best regards,
    Alexander
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Crane101
    Crane101 avatar
    2 posts
    Member since:
    Jul 2010

    Posted 12 Sep 2011 Link to this post

    Brilliant - thanks very much for that. Kinda obvious once you've got the answer!

    Shane
  5. Aravind
    Aravind avatar
    21 posts
    Member since:
    Oct 2015

    Posted 22 Oct 2015 in reply to Alexander Link to this post

    Can you please tell how to edit this??

     

    I tried including the following code, so that a new row is created when you press enter WHILE YOU'RE EDITING one particular cell.


    $(document).on('keypress','#grid',function(event){
        var keycode = (event.keyCode ? event.keyCode : event.which);
      if(keycode == '13'){
        grid.addRow();

      } 
    });

  6. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 22 Oct 2015 Link to this post

    Hello Aravind,

    Thank you for writing.

    Note that this forum is related to the UI for WinForms product. However, your question seems to be related to Kendo UI. I would kindly ask you to post your question in the appropriate forum: http://www.telerik.com/forums/kendo-ui.

    Thank you for your understanding.

    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. QuizzBox
    QuizzBox avatar
    46 posts
    Member since:
    Jan 2011

    Posted 09 Dec 2015 Link to this post

    Don't forget to set MultiLine to true before ;)
  8. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 10 Dec 2015 Link to this post

    Hello Nermond,

    Thank you for writing.

    Indeed, it is necessary to enable the multiline text for the editor as well:
    public Form1()
    {
        InitializeComponent();
     
        foreach (GridViewColumn col in this.radGridView1.Columns)
        {
            GridViewTextBoxColumn tbCol = col as GridViewTextBoxColumn;
            if (tbCol != null)
            {
                tbCol.AcceptsReturn = true;
            }
        }
    }
     
    private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
    {
        RadTextBoxEditor tbEditor = e.ActiveEditor as RadTextBoxEditor;
        if (tbEditor != null)
        {
            RadTextBoxEditorElement element = tbEditor.EditorElement as RadTextBoxEditorElement;
            element.TextBoxItem.Multiline = true;
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready