Using flow breaks in a context menu

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.
 
Top