We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,590 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

ToolStripDropDown auto-position problem

I have a custom combobox as below

public class ListViewCombo : ComboBox
{   
    ToolStripControlHost listViewHost;
    ToolStripDropDown dropDown;
    public ListViewCombo()
    {
        ListView lstView = new ListView();
        lstView.BorderStyle = BorderStyle.None;
        listViewHost = new ToolStripControlHost(lstView);
        dropDown = new ToolStripDropDown();
        dropDown.Items.Add(listViewHost);
    }

    public ListView TListView
    {
        get { return listViewHost.Control as ListView; }
    }

    private void ShowDropDown()
    {
        if (dropDown != null)
        {
            listViewHost.Width = DropDownWidth;
            listViewHost.Height = DropDownHeight;
            dropDown.Show(this,new Point(this.Loation.X, this.Height),ToolStripDropDownDirection.BelowRight);
        }
    }

    private const int WM_USER = 0x0400,
                      WM_REFLECT = WM_USER + 0x1C00,
                      WM_COMMAND = 0x0111,
                      CBN_DROPDOWN = 7;

    public static int HIWORD(int n)
    {
        return (n >> 16) & 0xffff;
    }

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == (WM_REFLECT + WM_COMMAND))
        {
            if (HIWORD((int)m.WParam) == CBN_DROPDOWN)
            {
                ShowDropDown();
                return;
            }
        }
        base.WndProc(ref m);
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            if (dropDown != null)
            {
                dropDown.Dispose();
                dropDown = null;
            }
        }
        base.Dispose(disposing);
    }
  }
 }

Every thing is good except when I move the form towards right or left of the screen to partially hide the custom combobox and clicks the dropdown button, then the dropdown automatically adjusts the location and fully displayed. That is even if the combobox is not displayed completely in the screen, the dropdownlist completely displayed by adjusting its position.

Is the ToolStripDropDown has no bounds constrain?.

1
Contributor
0
Replies
11
Views
kaizen202
Light Poster
33 posts since Dec 2007
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0635 seconds using 2.69MB