Live Chat Icon For mobile
Live Chat Icon

Is there any way to get to the Edit control or the editHandle of a ComboBox using safe code

Platform: WinForms| Category: Win32

Bill Zhang (Microsoft) responds to this question in a posting on microsoft.public.dotnet.frameworks.windowsforms newsgroup.

The Frameworks classes use P/Invoke to call the GetWindow API to get the HWND internally - there is no exposed way to do this. If you wish to get the Win32 HWND, here’s the code to do it, but there is no way to get a 
System.Windows.Forms.Edit control from this.

        [DllImport('user32.dll', ExactSpelling=true, CharSet=CharSet.Auto)]
        public static extern IntPtr GetWindow(IntPtr hWnd, int uCmd);

        public const int GW_CHILD = 5;

        if (combo.DropDownStyle != ComboBoxStyle.DropDownList) {
            IntPtr hwnd = GetWindow(combo.Handle, NativeMethods.GW_CHILD);
            if (hwnd != IntPtr.Zero) {
                editHandle = hwnd;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.