Setting focus in UltraTextEditor programatically

Posted by Peter Judge on 14-Jul-2010 10:35

I'm having a real "duh" moment here; I'm sure this is easy but it's turning out not to be. For the UserControl below, I'd like to specify the input focus to the uxUser text editor. I thought I would just need to set the ActiveControl and/or call Focus() on it, but this isn't working - focus stays on the uxPortal combo editor, which precedes the text editor in the tab order.

Any thoughts? Help?

thanks,

-- peter

class UI.PortalConnectPanel inherits Progress.Windows.UserControl:            define private variable components as System.ComponentModel.IContainer no-undo.     define private variable uxInputPanel as Infragistics.Win.Misc.UltraPanel no-undo.     define private variable uxUser as Infragistics.Win.UltraWinEditors.UltraTextEditor no-undo.     define private variable uxPortal as Infragistics.Win.UltraWinEditors.UltraComboEditor no-undo.     define private variable uxPassword as Infragistics.Win.UltraWinEditors.UltraTextEditor no-undo.     define private variable uxLogin as Infragistics.Win.Misc.UltraButton no-undo.     define private variable uxCancel as Infragistics.Win.Misc.UltraButton no-undo.     define private variable lblUser as Infragistics.Win.Misc.UltraLabel no-undo.     define private variable lblPortal as Infragistics.Win.Misc.UltraLabel no-undo.     define private variable lblPassword as Infragistics.Win.Misc.UltraLabel no-undo.     define private variable imageList1 as System.Windows.Forms.ImageList no-undo.


     constructor public PortalConnectPanel (  ):

        super().

        InitializeComponent().

        uxPortal:Value = uxPortal:Items[0].

        this-object:ActiveControl = uxUser.       

        this-object:ActiveControl:Focus().

        catch e as Progress.Lang.Error:

            undo, throw e.

        end catch.

     end constructor.

All Replies

Posted by Admin on 14-Jul-2010 12:44

METHOD OVERRIDE PROTECTED VOID OnLoad( INPUT e AS System.EventArgs ):

SUPER:OnLoad(INPUT e).

THIS-OBJECT:ActiveControl = uxUser.

END METHOD.

Posted by Peter Judge on 14-Jul-2010 12:54

Thanks - that works like a charm.

So the Load event is fired after the Form/UC is invoked; interesting.

-- peter

Posted by Admin on 14-Jul-2010 13:19

Check the MSDN for the actual wording! But it's fired just before the Form or UserControl are Shown the first time.

My feeling is, that this is similar to realizing Widgets in the ABL: the process of requesting the actual resources at the OS. There are some things (like DataBinding) that require that a Control has been loaded (which is different from jut instantiating).

This thread is closed