Thanks
20 Answers, 1 is accepted
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.
But I still can't find CellContentClick event, even in last version of telerik controls
Any workaround ?
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.
Svett
the Telerik team
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.
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
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.
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
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.
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
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.
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
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.
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
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
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
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
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
You dont have CellContentClick but you have CellClick event