Ticket A1102
Visible to All Users

How to obtain the CX editor corresponding to the ActiveControl property

created 21 years ago

Description:
When a TcxDBTextEdit is focused, the Screen.ActiveControl has the type TcxCustomInnerTextEdit. In my opinion, the ActiveControl should be of the type TcxDBTextEdit. How else could I determine if ActiveControl is of the type TcxTextEdit or TcxDBTextEdit?

Answer:
By design, our editors are wrappers (to support CX styles) for inner editors which implement the editing functionality. You may use code similar to the following to obtain the editor corresponding to a particular inner control:

Delphi
function GetEditor: TcxCustomEdit; var AControl: TWinControl; begin Result := nil; AControl := Screen.ActiveControl; if Supports(AControl, IcxInnerEditHelper) or Supports(AControl, IcxContainerInnerControl) then Result := TcxCustomEdit(AControl.Owner) else if AControl is TcxCustomEdit then Result := TcxCustomEdit(AControl); end;

See Also:
How to determine if a cxGrid is focused by using the ActiveControl property

Comments (2)

    I have used this function for  anumber of years successfully - but i have just noticed that recently it has started to fail.  If i call this with a standard edit box it is returning the owner of the control rather than the control itself.  I used this previously so that the memo control would return the owner control and the same for in place editors in a grid but this seems to return the owner for everything now?
    Any ideas why this has changed recently?

    DevExpress Support Team 11 years ago

      Hello,

      To process your recent post more efficiently, I created a separate ticket on your behalf: A1102: How to obtain the CX editor corresponding to the ActiveControl property. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.