Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 658577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:56:57+00:00 2026-05-13T22:56:57+00:00

I have a maximized form which has Combo-Box control (docked in top-right) with 500px

  • 0

I have a maximized form which has Combo-Box control (docked in top-right) with 500px Width

After trying to open the combo-box , the half of the list goes out-of-screen . how can I force list shows within form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:56:58+00:00Added an answer on May 13, 2026 at 10:56 pm

    Tricky problem. I could not find a good fix for this, merely a workaround. Add a new class and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form.

    The workaround is not a very good one. The problem is that the dropdown window will ignore the attempt to move it until the drop-down animation is complete. The visual effect is not great, you’ll see the window drop down, then jump to the left. I don’t know an other way to slap it over the head, maybe somebody else does.

    C# version:

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    public class MyComboBox : ComboBox {
      protected override void OnDropDown(EventArgs e) {
        // Is dropdown off the right side of the screen?
        Point pos = this.PointToScreen(this.Location);
        Screen scr = Screen.FromPoint(pos);
        if (scr.WorkingArea.Right < pos.X + this.DropDownWidth) {
           this.BeginInvoke(new Action(() => {
            // Retrieve handle to dropdown list
            COMBOBOXINFO info = new COMBOBOXINFO();
            info.cbSize = Marshal.SizeOf(info);
            SendMessageCb(this.Handle, 0x164, IntPtr.Zero, out info);
            // Move the dropdown window
            RECT rc;
            GetWindowRect(info.hwndList, out rc);
            int x = scr.WorkingArea.Right - (rc.Right - rc.Left);
            SetWindowPos(info.hwndList, IntPtr.Zero, x, rc.Top, 0, 0, 5);
          }));
        }
        base.OnDropDown(e);
      }
    
      // P/Invoke declarations
      private struct COMBOBOXINFO {
        public Int32 cbSize;
        public RECT rcItem, rcButton;
        public int buttonState;
        public IntPtr hwndCombo, hwndEdit, hwndList;
      }
      private struct RECT {
        public int Left, Top, Right, Bottom;
      }
      [DllImport("user32.dll", EntryPoint = "SendMessageW", CharSet = CharSet.Unicode)]
      private static extern IntPtr SendMessageCb(IntPtr hWnd, int msg, IntPtr wp, out COMBOBOXINFO lp);
      [DllImport("user32.dll")]
      private static extern bool SetWindowPos(IntPtr hWnd, IntPtr after, int x, int y, int cx, int cy, int flags);
      [DllImport("user32.dll")]
      private static extern bool GetWindowRect(IntPtr hWnd, out RECT rc);
    }
    

    VB.Net version:

    Imports System
    Imports System.Drawing
    Imports System.Windows.Forms
    Imports System.Runtime.InteropServices
    
    Public Class MyComboBox
        Inherits ComboBox
    
        'P/Invoke declarations
        Private Structure COMBOBOXINFO
            Public cbSize As Int32
            Public rcItem As RECT
            Public rcButton As RECT
            Public buttonState As Integer
            Public hwndCombo As IntPtr
            Public hwndEdit As IntPtr
            Public hwndList As IntPtr
        End Structure
    
        Private Structure RECT
            Public Left As Integer
            Public Top As Integer
            Public Right As Integer
            Public Bottom As Integer
        End Structure
    
    
        <DllImport("user32.dll", EntryPoint:="SendMessageW", CharSet:=CharSet.Unicode)>
        Private Shared Function SendMessageCb(hWnd As IntPtr, msg As Integer, wp As IntPtr, ByRef lp As COMBOBOXINFO) As IntPtr
        End Function
    
        <DllImport("user32.dll")>
        Private Shared Function SetWindowPos(hWnd As IntPtr, after As IntPtr, x As Integer, y As Integer, cx As Integer, cy As Integer, flags As Integer) As Boolean
        End Function
    
        <DllImport("user32.dll")>
        Private Shared Function GetWindowRect(hWnd As IntPtr, ByRef rc As RECT) As Boolean
        End Function
    
    
        Protected Overrides Sub OnDropDown(e As EventArgs)
              ' Is dropdown off the right side of the screen?
              Dim pos As Point = Me.PointToScreen(Me.Location)
              Dim scr As Screen = Screen.FromPoint(pos)
    
              If (scr.WorkingArea.Right < pos.X + Me.DropDownWidth) Then
                  Me.BeginInvoke(New Action(Sub()
    
                                                'Retrieve handle to dropdown list
                                                Dim info As COMBOBOXINFO = New COMBOBOXINFO()
                                                info.cbSize = Marshal.SizeOf(info)
                                                SendMessageCb(Me.Handle, &H164, IntPtr.Zero, info)
                                                'Move the dropdown window
                                                Dim rc As RECT
                                                GetWindowRect(info.hwndList, rc)
                                                Dim x As Integer = scr.WorkingArea.Right - (rc.Right - rc.Left)
                                                SetWindowPos(info.hwndList, IntPtr.Zero, x, rc.Top, 0, 0, 5)
                                            End Sub))
              End If
    
              MyBase.OnDropDown(e)
    
        End Sub
    
    
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JComboBox which contains an MRU list combo-box and a for a
I have a windows form application which needs to be the TopMost. I've set
We have an MDI form which contains some number of child forms which have
I have created a form in access 2010, in which there is a show
I have a C# form on which controls are laid and I have set
I have a form on which i want to place certain controls. I want
I have a main form, which is invisible and at some point creates a
I have a windows form application in which the Form1 object's initial WindowState ==
I have a form I set to Maximized , but for some reason it's
I have made a class which a form can inherit from and it handles

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.