Using flow breaks in a context menu

  • Thread starter Thread starter Aviad Pineles
  • Start date Start date
A

Aviad Pineles

I am trying to create a context menu strip (ContextMenuStrip object) that has
labels and textboxes (similar to the 'Filter For:' menu item when right
clicking on a record in a table view in MS access 2003).

I’ve written the following code, but it doesn’t do the trick:

ContextMenuStrip mnu=new ContextMenuStrip();
mnu.AutoSize = false;
mnu.Width = 400;
mnu.Height = 100;
mnu.LayoutStyle = ToolStripLayoutStyle.Flow;
FlowLayoutSettings fls = mnu.LayoutSettings as FlowLayoutSettings;
fls.FlowDirection = FlowDirection.LeftToRight;
//
// label1
//
ToolStripLabel label1 = new ToolStripLabel("Label1");
label1.Name = "label1";
mnu.Items.Add(label1);
//
// textbox1
//
ToolStripTextBox textbox1 = new ToolStripTextBox("textbox1");
textbox1.BorderStyle = BorderStyle.FixedSingle;
mnu.Items.Add(textbox1);
fls.SetFlowBreak(textbox1, true);
//
// label2
//
ToolStripLabel label2 = new ToolStripLabel("Label2");
label2.Name = "label2";
mnu.Items.Add(label2);
//
// textbox2
//
ToolStripTextBox textbox2 = new ToolStripTextBox("textbox2");
textbox2.BorderStyle = BorderStyle.FixedSingle;
mnu.Items.Add(textbox2);
fls.SetFlowBreak(textbox2, true);

Note that I am trying to set a flow break after each text box, but no flow
breaks actually happen, all the controls appear side by side on one line.

What am I doing wrong? Am I applying the flow break on the wrong object?
I’ve tried to apply it to textbox.Control and textbox.TextBox to no avail…

Thanks,
Aviad.
 
You need to call SetFlowBreak before adding the item to the menu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top