5 Answers, 1 is accepted
I found a resolution:
METHOD PUBLIC VOID element_SelectedValueChanged( sender AS System.Object, e AS Telerik.WinControls.UI.Data.ValueChangedEventArgs ):
DEFINE BUFFER btt-CSCompliance FOR tt-CSCompliance.
DEFINE VARIABLE currentCell AS GridViewCellInfo NO-UNDO.
IF gvCompliance:CurrentColumn:Index = 0 THEN DO:
currentCell = gvCompliance:CurrentRow:Cells:Item[0].
currentCell:EndEdit().
END.
RETURN.
END METHOD.
But now I've got the next problem.
This works only for the first row/cell.
I think something missed after called the EndEdit()-Method.
Next time I've got a NullReferenceException.
Regards
If I understand your requirement correctly, you need to detect when a new selection is made in the editor for the GridViewComboBoxColumn. For this purpose, you can use the CellEditorInitialized event where you have access to the RadDropDownListEditor and handle the RadDropDownListEditorElement.SelectedIndexChanged event as follows:
this
.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
private
void
radGridView1_CellEditorInitialized(
object
sender, GridViewCellEventArgs e)
{
RadDropDownListEditor ddl = e.ActiveEditor
as
RadDropDownListEditor;
if
(ddl !=
null
)
{
RadDropDownListEditorElement el = ddl.EditorElement
as
RadDropDownListEditorElement;
el.SelectedIndexChanged -= el_SelectedIndexChanged;
el.SelectedIndexChanged += el_SelectedIndexChanged;
}
}
private
void
el_SelectedIndexChanged(
object
sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
Console.WriteLine(e.Position);
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Progress Telerik
Hello Dess,
this is what I'm doing now.
I've forgotten the BeginEdit() after I set the EndEdit() manually.
METHOD PUBLIC VOID element_SelectedValueChanged( sender AS System.Object, e AS Telerik.WinControls.UI.Data.ValueChangedEventArgs ):
DEFINE VARIABLE currentCell AS GridViewCellInfo NO-UNDO.
IF gvCompliance:CurrentColumn:Index = 0 THEN DO:
currentCell = gvCompliance:CurrentRow:Cells:Item[0].
/* EndEdit() setzen, um CellValueChanged auszulösen */
currentCell:EndEdit().
END. /* IF gvCompliance:CurrentColumn:Index = 0 THEN DO: */
RETURN.
END METHOD.
METHOD PRIVATE VOID gvCompliance_CellEditorInitialized( INPUT sender AS System.Object, INPUT e AS Telerik.WinControls.UI.GridViewCellEventArgs ):
DEFINE VARIABLE myEditor AS RadDropDownListEditor NO-UNDO.
DEFINE VARIABLE myElement AS RadDropDownListEditorElement NO-UNDO.
DEFINE VARIABLE currentCell AS GridViewCellInfo NO-UNDO.
myEditor = CAST(e:ActiveEditor, RadDropDownListEditor) NO-ERROR.
IF myEditor <> ? THEN DO:
myElement = CAST(myEditor:EditorElement, RadDropDownListEditorElement) NO-ERROR.
myElement:SelectedValueChanged:Unsubscribe(element_SelectedValueChanged).
myElement:SelectedValueChanged:Subscribe(element_SelectedValueChanged).
currentCell = gvCompliance:CurrentRow:Cells:Item[0].
currentCell:BeginEdit().
END. /* IF myEditor <> ? THEN DO: */
RETURN.
END METHOD.
Now, everything is ok.
Regards
I hope that the previous code snippet was useful for your case. Note that by default when you make a new selection from the drop down, the editor is not closed. It seems that you call the EndEdit method that closes the editor. The CellEditorInitialized event is fired when you already activated the editor. Hence, calling the BeginEdit method is not necessary in this event handler. It is difficult from the brief code snippet to get better understanding for the complete scenario that you have. But if the current behavior suits your requirement feel free to use it.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Progress Telerik