Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > ToolStripComboBox displays in incorrect location
 

ToolStripComboBox displays in incorrect location

Hi All,

When the we add ToolStripComboBox in a ToolStripMenuItem in the ContextMenustrip's opening event, displays the ToolStripComboBox in the TopLeft corner of the screen when displaying for the second time.

create a sample using the below code.
Right click the item in list box.
Click the menu item.
Notice the combobox
Again right click the item in list box.
Click the menu item
Notice the combobox location.


The issue is reproduced only when adding the ToolStripmenuitem at runtime in Contrextmenustrip's opening event.

code I used:

ToolStripComboBox _MenuComboBoxItem;
ToolStripComboBox _MenuComboBoxItem2;
public Form1()
{
InitializeComponent();
this.listBox1.ContextMenuStrip = contextMenuStrip1;
this.listBox1.Items.Add("test");

_MenuComboBoxItem = new ToolStripComboBox();
_MenuComboBoxItem.Text = "test";
_MenuComboBoxItem.ToolTipText = "test";
_MenuComboBoxItem.Items.AddRange(new string[] { "Test1", "Test2", "Test3", "Test4" });

_MenuComboBoxItem2 = new ToolStripComboBox();
_MenuComboBoxItem2.Text = "test";
_MenuComboBoxItem2.ToolTipText = "test";
_MenuComboBoxItem2.Items.AddRange(new string[] { "Test1", "Test2", "Test3", "Test4" });
}

private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
contextMenuStrip1.Items.Clear();

ToolStripMenuItem mainItem = new ToolStripMenuItem("TEST: ");

contextMenuStrip1.Items.Add(mainItem);
mainItem.DropDownItems.Add(_MenuComboBoxItem);
//Adding two ToolStripComboBoxEx does not cause the issue
//mainItem.DropDownItems.Add(_MenuComboBoxItem2);
e.Cancel = false;
}


Regards,
Shiny

Shine Nalini  Tuesday, March 24, 2009 10:48 AM
Hi....!

Any reply..? Is it a bug?

-Shiny
Shine Nalini  Friday, May 15, 2009 4:04 AM

You can use google to search for other answers

Custom Search

More Threads

• Anyone know where all the Terrarium samples went ?
• Hebrew localization
• Datasets in WebServices for CE.Net
• .Net Terrarium
• Server Database Creature Data
• C# source avaliable!!!
• Destroyed because of error
• Exception Error
• Terrarium Server Available
• where can i find tutorials or ebooks about advanced and proffessioal .Net programming techniques or ways