0

I use the F# code below to read an input from a ToolStripTextBox.

My problem is that I could not make the ToolStripTextBox resize when the form is resized (like the URL field in a browser).

Any suggestions?

Among others I tried the suggestion in this form (with the right syntax), though it did not work.

My form is very similar to the code in the book "Expert F# 3.0", page 429.

open System.Windows.Forms


let form = new Form(Size=new Size(780, 560))

...       

let toolbar = new ToolStrip(Dock=DockStyle.Top, Name="Toolbar")
toolbar.Location <- new Point(50,25) 
...    
let input = new ToolStripTextBox(Size= new Size(600,25))

...

let go = new ToolStripButton(DisplayStyle=ToolStripItemDisplayStyle.Text,Text="Reduce",Visible=true)

toolbar.Items.Add(new ToolStripLabel("Input:")) |> ignore
toolbar.Items.Add(input) |> ignore
toolbar.Items.Add(go) |> ignore 
4

1 回答 1

1

The following code solves the problem:

form.ClientSizeChanged.Add ( fun arg -> input.Size <- new System.Drawing.Size(form.Size.Width - 160, 25))
于 2014-10-06T13:00:53.667 回答