GoDigram for .NET Framework and .NET Core
Northwoods.Go Namespace / GoText Class / CreateEditor Method
In This Topic
    CreateEditor Method (GoText)
    In This Topic
    This creates a GoControl that will create a TextBox, a ComboBox, or a NumericUpDown when the GoControl is painted in a GoView.
    Syntax
    public override GoControl CreateEditor( 
       GoView view
    )

    Parameters

    view
    Remarks

    This is responsible for creating a GoControl with the appropriate GoControl.ControlType and bounds. This method is called by DoBeginEdit. If you want to set some properties on the Control created by the GoControl for a GoView, it is probably easiest to override the DoBeginEdit method.

    For more general customization you will define a subclass of Control and override this method as follows:

    
                public override GoControl CreateEditor(GoView view) {
                  GoControl editor = base.CreateEditor(view);
                  if (editor != null) editor.ControlType = typeof(MyCustomControl);
                  return editor;
                }
                
    You may also want to adjust the Bounds of the resulting GoControl.

    Your subclass of Control, MyCustomControl, which should implement the IGoControlObject interface, should be responsible for initializing itself correctly for this GoText object. That initialization is normally done when IGoControlObject.GoControl is set. It will of course want to examine this GoText object being edited; you can get that with the following expression:

    
                  this.GoControl.EditedObject as GoText
                

    When your Control is finished editing, it may want to save its results by modifying this GoText object. In particular, if you want to change the Text property, it is best to do something like:

    
                  GoControl goctrl = this.GoControl;
                  if (goctrl != null) {
                    GoText gotext = goctrl.EditedObject as GoText;
                    if (gotext == null || gotext.DoEdit(this.GoView, gotext.Text, newtextvalue)) {
                      goctrl.DoEndEdit(this.GoView);
                    }
                  }
                
    This calls DoEdit which permits validation using both the old and the proposed new text strings, before actually setting the Text property.

    Your IGoControlObject Control should terminate by calling:

    
                  this.GoControl.DoEndEdit(this.GoView)
                
    in its event handlers that cause it to finish.

    See Also