Add event handlers on editors

3 posts, 1 answers
  1. Lorenzo
    Lorenzo avatar
    4 posts
    Member since:
    Nov 2012

    Posted 21 May 2014 Link to this post

    Hello,


    I am looking for a way to control when a cell is edited in a GanttViewTextViewCellElement. If certain conditions are met, the old value should be reset. How and when should I add handlers?

    I am thinking on the editors of each cellElement but I dont know how to reach them in a way like in Gridview where the CellBeginEdit event is handy for it.

    Thanks,
    Lorenzo.
  2. Lorenzo
    Lorenzo avatar
    4 posts
    Member since:
    Nov 2012

    Posted 21 May 2014 in reply to Lorenzo Link to this post

    Hello again.

    I forgot to say that I haven't found an event that appears in the documentation for GanttView controls: "EditorRequired". I suppose that it wold be a nice place to attach an event handler.

    Regards,
    Lorenzo
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 26 May 2014 Link to this post

    Hello Lorenzo,

    Thank you for writing.

    It is possible to perform validation of the editor's valueбъ subscribing to the ValueChanging event for the respective editor. Here is a sample code snippet, demonstrating how to use the GanttViewElement.EditorInitialized event and subscribe to the GanttViewDateTimeEditor.ValueChanging event, which can be canceled when the new value is not valid:
    private void GanttViewElement_EditorInitialized(object sender, GanttViewItemEditorInitializedEventArgs e)
    {
        GanttViewDateTimeEditor dtEditor = e.Editor as GanttViewDateTimeEditor;
        if (dtEditor != null)
        {
            dtEditor.ValueChanging-=dtEditor_ValueChanging;
            dtEditor.ValueChanging+=dtEditor_ValueChanging;
        }
    }
     
    private void dtEditor_ValueChanging(object sender, ValueChangingEventArgs e)
    {
        if ("New value is not valid")
        {
               e.Cancel = true;
        }       
    }

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top