This is a migrated thread and some comments may be shown as answers.

No CellContentClick in RadGridView

20 Answers 506 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jeff torririt
Top achievements
Rank 1
jeff torririt asked on 14 Jan 2010, 03:52 AM
There is no CellContentClick in RadGridView Compare to dataGridView. is there another way to implement event in radgridview just like CellContentClick?

Thanks

20 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 15 Jan 2010, 09:15 AM
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.
0
Solaris
Top achievements
Rank 1
answered on 28 Nov 2012, 12:48 PM
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 ?
0
Svett
Telerik team
answered on 30 Nov 2012, 08:47 AM
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.
0
Solaris
Top achievements
Rank 1
answered on 30 Nov 2012, 01:32 PM
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.


0
Svett
Telerik team
answered on 05 Dec 2012, 10:13 AM
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.
0
Solaris
Top achievements
Rank 1
answered on 06 Dec 2012, 07:48 PM
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.
0
Svett
Telerik team
answered on 11 Dec 2012, 10:57 AM
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.
0
Solaris
Top achievements
Rank 1
answered on 11 Dec 2012, 02:45 PM
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.
0
Svett
Telerik team
answered on 14 Dec 2012, 11:11 AM
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.
0
Solaris
Top achievements
Rank 1
answered on 14 Dec 2012, 09:34 PM
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.
0
Jack
Telerik team
answered on 19 Dec 2012, 11:53 AM
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.
0
Solaris
Top achievements
Rank 1
answered on 19 Dec 2012, 08:44 PM
Jack,Svett thank you very much for support!!
0
Solaris
Top achievements
Rank 1
answered on 20 Dec 2012, 04:43 PM
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.
0
Jack
Telerik team
answered on 21 Dec 2012, 12:08 PM
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.
0
Solaris
Top achievements
Rank 1
answered on 25 Dec 2012, 03:43 PM
Thanks!! Worked perfectly!
0
keerthi
Top achievements
Rank 1
answered on 08 Dec 2016, 11:56 AM
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
0
Hristo
Telerik team
answered on 09 Dec 2016, 11:44 AM
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 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.
0
darwin
Top achievements
Rank 1
answered on 06 Feb 2019, 07:01 PM

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

0
Hristo
Telerik team
answered on 07 Feb 2019, 07:21 AM
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.
0
Pedro Filipe
Top achievements
Rank 1
answered on 07 Feb 2019, 12:11 PM

You dont have CellContentClick but you have CellClick event

 

 

Tags
GridView
Asked by
jeff torririt
Top achievements
Rank 1
Answers by
Svett
Telerik team
Solaris
Top achievements
Rank 1
Jack
Telerik team
keerthi
Top achievements
Rank 1
Hristo
Telerik team
darwin
Top achievements
Rank 1
Pedro Filipe
Top achievements
Rank 1
Share this question
or