CellDoubleClick on Edit mode

5 posts, 0 answers
  1. Mehdi
    Mehdi avatar
    6 posts
    Member since:
    Sep 2017

    Posted 06 Sep 2017 Link to this post

    Hi.

    I'm using 2017 R2. 

    want to open new form, when cell double click. but I need to cell NOT on read only.

    In other word, I'm need a RadGridView, with a cell edit mode, and double click event to open a new form.

    im using snipped code, but this code have a problem, when user click on cell, event counter +1 , and after 2 or 3 One click on cell, and after double click on a cell, event void HostedControl_DoubleClick run for event count. 

     

    01.private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
    02.        {
    03.            RadTextBoxEditor editor = e.ActiveEditor as RadTextBoxEditor;
    04.            RadTextBoxEditorElement element = editor.EditorElement as RadTextBoxEditorElement;
    05.            if (e.ColumnIndex == 0 || e.ColumnIndex == 1)
    06.            {
    07.                if (editor != null)
    08.                {
    09.                    element.TextBoxItem.HostedControl.DoubleClick += new EventHandler(HostedControl_DoubleClick);
    10.                }
    11.            }
    12.        }
    13. 
    14.        void HostedControl_DoubleClick(object sender, EventArgs e)
    15.        {
    16.            if (new FrmGheteDir().ShowDialog() == DialogResult.OK)
    17.            {
    18.                _gheteId = FrmGheteDir.Gheteid;
    19.                var ghete = (from u in _db.GheteStore where u.GheteId == _gheteId select u).First();
    20.                radGridView1.CurrentRow.Cells[0].Value = ghete.GheteId;
    21.                radGridView1.CurrentRow.Cells[1].Value = ghete.GheteList.Name;
    22.                radGridView1.CurrentRow.Cells[3].Value = ghete.LastPriceIn;
    23.             
    24.            }
    25.        }
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3532 posts

    Posted 08 Sep 2017 Link to this post

    Hello Mehdi, 

    Thank you for writing.  

    By default, when you click a cell for the first time it gets selected. If you click it for a second time, the editor is being initialized. Once the editor is activated, when you click another cell, it directly enters edit mode. I would recommend you to set the BeginEditMode property for RadGridView to BeginEditProgrammatically. Thus, you can control when to activate the editor when calling the BeginEdit method, e.g. in CellDoubleClick event, and show the desired form.

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Mehdi
    Mehdi avatar
    6 posts
    Member since:
    Sep 2017

    Posted 09 Sep 2017 Link to this post

    Hi Dess.

    Thanks for info, but this is not solution.

    I'm need radGridView , with active edit mode with one click. When user one click on cell, Edit mode active and user can input somthing ther. and if user double click on cell, (on edit mode or not) new form must be show.

    but a problem there, on edit mode, cell double click not fire.

    have a solution for it ?

     

  4. Mehdi
    Mehdi avatar
    6 posts
    Member since:
    Sep 2017

    Posted 09 Sep 2017 Link to this post

    Add to last post,

    microsoft DataGridView, worked perfectly. one click on cell, enable EditMode, and double click, event fire and new form showing.

  5. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3532 posts

    Posted 13 Sep 2017 Link to this post

    Hello Mehdi, 

    Thank you for writing back. 

    As it was noted in my previous post, the first click over a cell selects that cell, the second click will activate the editor. Once the editor is activated and you select another cell, this cell automatically enters edit mode. This is by design. If you need to activate the editor each time with a single click, it is necessary to set the BeginEditMode property for RadGridView to BeginEditProgrammatically and handle the CellClick event and call the BeginEdit method. Then, in the CellEditorInitialized event, you can show the desired dialog. Here is a sample code snippet: 
    public RadForm1()
    {
        InitializeComponent();
     
        this.radGridView1.BeginEditMode = Telerik.WinControls.RadGridViewBeginEditMode.BeginEditProgrammatically;
        this.radGridView1.CellClick+=radGridView1_CellClick;
        this.radGridView1.CellEditorInitialized+=radGridView1_CellEditorInitialized;
    }
     
    private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
    {
        new RadForm().ShowDialog();
    }
     
    private void radGridView1_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
    {
        this.radGridView1.BeginEdit();
    }

    However, activating the editor with a single click will prevent the CellDoubleClick event to be fired. Once the editor has been activated the keyboard input will be handled by the editor. That is why in the CellEditorInitialized event you can subscribe to the desired event for the editor to handle some keyboard input for example.

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top