Hello
I have a gridview in which I have added a GridViewCheckBoxColumn
I have not found which event is fired when I click on the check box and how to get the value of the checkbos (checked or not) without leaving the cell.
In other word how can I catch the click on the check bos and test its value.
the CellValueChanged event is fired only when I leave the cell ...
the CellClick Event allows me to get the cell but not the checkbox value ..
Any idea ?
Thanks in advance
8 Answers, 1 is accepted
Have you tried handling the ValueChanged event?
private
void
radGridView1_ValueChanged(
object
sender, EventArgs e)
{
string
msg =
""
;
try
{
if
(radGridView1.ActiveEditor
is
RadCheckBoxEditor && radGridView1.CurrentCell.RowIndex >= 0)
{
if
(checkState ==
"On"
)
{
// do something
}
else
if
(checkState ==
"Off"
)
{
// do something
}
}
}
catch
(Exception ex)
{
msg = ex.Message.ToString();
}
}
I forgot to add where the value checkState comes from.
private
void
radGridView1_ValueChanged(
object
sender, EventArgs e)
{
string
msg =
""
;
try
{
if
(radGridView1.ActiveEditor
is
RadCheckBoxEditor && radGridView1.CurrentCell.RowIndex >= 0)
{
string
checkState = rgvReportList.ActiveEditor.Value.ToString();
if
(checkState ==
"On"
)
{
// do something
}
else
if
(checkState ==
"Off"
)
{
// do something
}
}
}
catch
(Exception ex)
{
msg = ex.Message.ToString();
}
}
Hello thanks for your information
Yes I have tried the valuechanged event, but is is fired when I "leave" the cell that contains the CheckBox, I would like an event that is fired when I click the checkbox, without leaving the cell and a property that tells me if the checkbox is checked or not.
OK thanks to your input I found the solution:
1. I Declare a checkEditor
Private WithEvents Checkeditor As RadCheckBoxEditor
2. In the CellEditorInitialized event I instanciate the checkbox
If TypeOf e.ActiveEditor Is RadCheckBoxEditor Then
Checkeditor = e.ActiveEditor
End If
3. The CheckEditor has an event ValueChanged that is fired a every click in the check box and
the checkeditor.value property is "off" or "on", combined with the grid currentrow I have all I need
Thanks for your suggestions that have sent me in the right direction
Best Regards
I am glad that you have discussed the scenario with clicking a cell inside a GridViewCheckBoxColumn.
However, please have in mind that the GridViewCheckBoxColumn offers the EditMode property. This property determines whether changing a value of a check box will immediately be send to the cell (OnValueChange) or when the current cell is changed or the grid is being validated (OnCellChangeOrValidating). Feel free to set the EditMode property to OnValueChange and handle the CellValueChanged event. In this case, the event will be fired as soon as you click a checkbox.
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).
Hello Dess
Thanks for this complement of information, it clearly is a more straight forward mechanism to handle the Click Event on the checkBox.
I will modify my code to handle the click event as you suggest
Best Regards
Pierre-Jean