Disable context menu when editing cell

6 posts, 0 answers
  1. Yariv
    Yariv avatar
    2 posts
    Member since:
    Jan 2012

    Posted 14 Jun 2013 Link to this post

    Hi,

    I've created a grid with one editable column.
    Can you please advise how I can totally disable context menu that becomes accessable when editing, or disable some specific menu points (e.g. "Insert Unicode control character", "Right to left Reading order" etc.)?

    Thanks in advance.
  2. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 19 Jun 2013 Link to this post

    Hello Yariv,

    Thank you for writing.

    Most of our editors internally host the standard TextBox control, thus the context menu that you are seeing is the standard TextBox context menu. To remove it, you need to access this text box and set its ContextMenu property to a new instance of ContextMenu. To access the TextBox, you need to access the editor for the edited cell. Assuming that you have GridViewTextBoxColumn, the cells in this column use RadTextBoxEditor. To access the editor you need to subscribe to the CellEditorInitialized event. Here is a sample:
    void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        RadTextBoxEditor editor = e.ActiveEditor as RadTextBoxEditor;
     
        if (editor != null)
        {
            ((RadTextBoxEditorElement)editor.EditorElement).TextBoxItem.HostedControl.ContextMenu = new ContextMenu();
        }
    }

    I hope that you find this information useful.
     
    Regards,
    Stefan
    Telerik
    RadChart for WinForms is obsolete. Now what?
  3. Yariv
    Yariv avatar
    2 posts
    Member since:
    Jan 2012

    Posted 01 Jul 2013 Link to this post

    Hi Stefan,

    Thanks a lot, it helped!
  4. Alexander
    Alexander avatar
    3 posts
    Member since:
    May 2013

    Posted 17 Sep 2013 Link to this post

    It works for string type, but if column fill with int elements
    it doesn't help.
    What type instead RadTextBoxEditor I need use for INT?
  5. Alexander
    Alexander avatar
    3 posts
    Member since:
    May 2013

    Posted 17 Sep 2013 Link to this post

    Oh! I find it: GridSpinEditor)
  6. Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 18 Sep 2013 Link to this post

    Hello Alexander,

    Indeed, GridSpinEditor is the editor that you need when working with numbers. I am glad that you managed to find the answer and your case is resolved.

    Regards,
    Nikolay
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top