No CellContentClick in RadGridView

21 posts, 0 answers
  1. jeff torririt
    jeff torririt avatar
    8 posts
    Member since:
    Jan 2010

    Posted 13 Jan 2010 Link to this post

    There is no CellContentClick in RadGridView Compare to dataGridView. is there another way to implement event in radgridview just like CellContentClick?

    Thanks
  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 15 Jan 2010 Link to this post

    Hi jeff torririt,

    Thank you for feedback. Unfortunately, the event does not exist in current version of RadGridView. We are trying to cover all events that are in Microsoft DataGridView. We will address this event in some of the next versions.

    If you have further questions, feel free to ask us.

    Kind regards,
    Svett
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Solaris
    Solaris avatar
    8 posts
    Member since:
    Nov 2012

    Posted 28 Nov 2012 Link to this post

    Hi, almost 2 years past from this post.

    But I still can't find CellContentClick event, even in last version of telerik controls

    Any workaround ?
  4. Svett
    Admin
    Svett avatar
    728 posts

    Posted 30 Nov 2012 Link to this post

    Hello Soalris,

    Thank you for writing.

    There is an event which you can use to capture cell clicks - CellClick. To make sure that you clicked a data cell, you just need to add a check for this:
    void radGridView1_CellClick(object sender, GridViewCellEventArgs e)
    {
        GridDataCellElement dataCell = sender as GridDataCellElement;
     
        if (dataCell != null)
        {
              //data cell is clicked
        }
    }

    I hope this helps.

    Regards,
    Svett
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  5. Solaris
    Solaris avatar
    8 posts
    Member since:
    Nov 2012

    Posted 30 Nov 2012 Link to this post

    Hello Svett, thank you for your reply!

    Sorry,but I know about that event and in my situation it is not effective.

    To clarify what I want to do, consider such situation:

    I have a grid with GridViewCheckBox column. If I use the CellClick() event, then it will also fire even if user is not clicked directly on checkbox,it will fire whenever user clicks on column cell but not on checkbox directly, so that's why I need CellContentClick.

    Thanks in advance.
    Soalris.


  6. Svett
    Admin
    Svett avatar
    728 posts

    Posted 05 Dec 2012 Link to this post

    Hello Soalris,

    You can achieve the illustrated scenario by using the CellClick event in the following manner:
    private void radGridView1_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
    {
        GridCheckBoxCellElement checkBoxCellElement = sender as GridCheckBoxCellElement;
     
        if (checkBoxCellElement != null)
        {
            RadCheckBoxEditorElement element = checkBoxCellElement.Children[0] as RadCheckBoxEditorElement;
            Point mousPos = element.ElementTree.Control.PointToClient(Control.MousePosition);
     
            if (element != null && element.Checkmark.ControlBoundingRectangle.Contains(mousPos))
            {
                //checkbox is clicked
            }
        }
    }

    I hope this helps.

    All the best,
    Svett
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  7. Solaris
    Solaris avatar
    8 posts
    Member since:
    Nov 2012

    Posted 06 Dec 2012 Link to this post

    Hello Svett,

    and what if user selects cell and clicks space, which will check checkbox, but Click event will not fire.

    So should I implement 2 different handlers for that ?

    I think telerik need to consider adding ContentChanged event.

    Regards,
    Narek.
  8. Svett
    Admin
    Svett avatar
    728 posts

    Posted 11 Dec 2012 Link to this post

    Hi Soalris,

    In that case, you should use the ValueChanged event which is fired when editor's value is changed. You can read more about editor's events in the online documentation.

    Greetings,
    Svett
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  9. Solaris
    Solaris avatar
    8 posts
    Member since:
    Nov 2012

    Posted 11 Dec 2012 Link to this post

    Hi Svett, thanks for reply.

    When I use ValueChanged() event and check/uncheck checkbox that event simply not firing, until I'll select another cell. But I need to update my form data Immediately, depending on if checkbox checked or not

    Any other solution ?

    Regards,
    Soalris.
  10. Svett
    Admin
    Svett avatar
    728 posts

    Posted 14 Dec 2012 Link to this post

    Hi Soalris,

    I am not able to reproduce the issue. The ValueChanged event occurs when the editor's value is changed. Notice that the value is not committed to underlying data source. If you want to commit it, immediately you should invoke the EndEdit method of RadGridView inside the event handler. If the proposed solution does not resolve your case, I recommend opening support ticket where you can enclose a sample project where the issue occurs.

    Greetings,
    Svett
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  11. Solaris
    Solaris avatar
    8 posts
    Member since:
    Nov 2012

    Posted 14 Dec 2012 Link to this post

    Dear Svett, thank you very much!

    You was right, mistakenly I was using CellValueChanged() event, which was not firing whn I was changing checkbox value.
    ValueChanged() is what I need, but now another question - how can I know which row,column changed ?

    Regards,
    Soalris.
  12. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 19 Dec 2012 Link to this post

    Hello Soalris,

    The ValueChanged event fires when RadGridView is in edit mode. And the editor is applied only to the current cell. So, you can use one of the following grid properties to identify the cell: CurrentCell, CurrentRow, CurrentColumn.

    I hope this helps.
     
    Regards,
    Jack
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  13. Solaris
    Solaris avatar
    8 posts
    Member since:
    Nov 2012

    Posted 19 Dec 2012 Link to this post

    Jack,Svett thank you very much for support!!
  14. Solaris
    Solaris avatar
    8 posts
    Member since:
    Nov 2012

    Posted 20 Dec 2012 Link to this post

    Hi ValueChanged() is not functioning properly.

    Add RadGridView to your project with one checkbox column.
    Add this handler, which in my understanding must show the changed value of grid's current cell.

    Private Sub RadGridView1_ValueChanged(sender As System.Object, e As System.EventArgs) Handles RadGridView1.ValueChanged
            MsgBox(RadGridView1.CurrentCell.Value)
    End Sub

    But it is showing always same value, try to change same cell value couple of times without moving cursor into different cell, it will show only 1 value.

    What I need to do is this - I need to update immediately checked rows count.
  15. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 21 Dec 2012 Link to this post

    Hi Soalris,

    The checkbox editor behaves different compared to other editors in RadGridView. It is a permanent editor and it commits its value to the data layer when the current position in RadGridView (row or cell) changes. That is why the cell value is always the same. You can change this by calling the EndEdit method explicitly:
    Private Sub RadGridView1_ValueChanged(sender As System.Object, e As System.EventArgs) Handles RadGridView1.ValueChanged
            Me.RadGridView1.EndEdit()
            MsgBox(RadGridView1.CurrentCell.Value)
    End Sub

    Please note that ValueChanged event fires when an editor changes its value. You should handle the CellValueChanged event to track changes in cell values caused by an edit operation.
     
    Greetings,
    Jack
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  16. Solaris
    Solaris avatar
    8 posts
    Member since:
    Nov 2012

    Posted 25 Dec 2012 Link to this post

    Thanks!! Worked perfectly!
  17. keerthi
    keerthi avatar
    15 posts
    Member since:
    Dec 2016

    Posted 08 Dec 2016 Link to this post

    I created a radGridView control where the first column is a checkbox, and 4 are data columns.
    My requirement ,in below 3 cases checkbox should be checked
    1.When click occurs inside the check box.
    2.When click occurs  outside of the checkbox column in the row.
    3.when the click occurs in the cell but not in the checkboxPlease help to me how to write code by using gridviewcellclick and cellvaluechanged events
  18. Hristo
    Admin
    Hristo avatar
    1519 posts

    Posted 09 Dec 2016 Link to this post

    Hi Кeerthi,

    Thank you for writing back.

    You can achieve the desired result by handling the MouseDown event in the grid and toggling the boolean value of your check box column for the row on which the click has occurred. Please check the following code snippet: 
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
     
            DataTable dt = new DataTable();
            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Date", typeof(DateTime));
            dt.Columns.Add("Bool", typeof(bool));
            for (int i = 0; i < 500; i++)
            {
               dt.Rows.Add(i, "Name" + i, DateTime.Now.AddDays(i), i % 2 == 0);
            }
     
     
            this.radGridView1.DataSource = dt;
            this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
     
            this.radGridView1.MouseDown += radGridView1_MouseDown;
        }
     
        private void radGridView1_MouseDown(object sender, MouseEventArgs e)
        {
            if (this.radGridView1.IsInEditMode)
            {
                return;
            }
     
            RadGridView grid = (RadGridView)sender;
            RadElement element = grid.ElementTree.GetElementAtPoint(e.Location);
            if (element is RadCheckmark)
            {
                return;
            }
     
            GridDataCellElement dataCell = element as GridDataCellElement;
            if (dataCell == null)
            {
                RadElement parent = element.Parent;
                while (parent != null)
                {
                    if (parent is GridDataCellElement)
                    {
                        dataCell =  (GridDataCellElement)parent;
                        break;
                    }
     
                    parent = parent.Parent;
                }
            }
     
            if (dataCell != null)
            {
                dataCell.RowElement.RowInfo.Cells["Bool"].Value = !(bool)dataCell.RowElement.RowInfo.Cells["Bool"].Value;
            }
        }
    }

    I am also sending you a short video showing the result on my end.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
  19. darwin
    darwin avatar
    1 posts
    Member since:
    Jan 2019

    Posted 06 Feb 2019 Link to this post

    Private Sub datalistado_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles datalistado.CellContentClick
            'controlamos los checkbox de todas las filas de los registros mostramos en el datagridview
            If e.ColumnIndex = Me.datalistado.Columns.Item("Eliminar").Index Then
                Dim chkCell As DataGridViewCheckBoxCell = Me.datalistado.Rows(e.RowIndex).Cells("Eliminar")
                chkCell.Value = Not chkCell.Value
            End If
        End Sub

     

     

    no tengo la funcin CellContentClick en el radgrid, como soluciono esto

  20. Hristo
    Admin
    Hristo avatar
    1519 posts

    Posted 07 Feb 2019 Link to this post

    Hello Darwin,

    Please have in mind that we try to use English in the forums. This way your question will reach more people part of the community.

    Instead of creating the CellContentClick event as in the standard grid, we have exposed a CellClick event which will basically provide the same information. You can check one of the previous posts explaining how it can be handled.

    Regards,
    Hristo
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  21. Pedro Filipe
    Pedro Filipe avatar
    8 posts
    Member since:
    Jan 2019

    Posted 07 Feb 2019 in reply to darwin Link to this post

    You dont have CellContentClick but you have CellClick event

     

     

Back to Top