Advertisement
wandrake

Untitled

Feb 29th, 2012
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.94 KB | None | 0 0
  1.  
  2. open System.Windows.Forms
  3.  
  4. let form = new Form(Text = "Web browser", TopMost = true)
  5.  
  6. let webBrowser = new WebBrowser()
  7.  
  8. let browserPanel = new TableLayoutPanel()
  9.  
  10. browserPanel.RowCount <- 2
  11. browserPanel.ColumnCount <- 1
  12. browserPanel.Dock <- DockStyle.Fill
  13.  
  14. let panel = new Panel()
  15. panel.Dock <- DockStyle.Fill
  16.  
  17. let txtAddr = new TextBox()
  18. txtAddr.Dock <- DockStyle.Fill
  19.  
  20. let btnGo = new Button(Text = "Go!")
  21. btnGo.Dock <- DockStyle.Right
  22.  
  23. panel.Height <- txtAddr.Height
  24.  
  25. webBrowser.Dock <- DockStyle.Fill
  26.  
  27. let navigate (text: string) =
  28.     webBrowser.Navigate text
  29.  
  30. btnGo.Click.Add(fun _ ->
  31.     navigate txtAddr.Text
  32. )
  33.  
  34. txtAddr.KeyUp.Add(fun e ->
  35.     match e.KeyCode with
  36.     | Keys.Enter -> navigate txtAddr.Text
  37.     | _ -> ()
  38. )
  39.  
  40. panel.Controls.Add(txtAddr)
  41. panel.Controls.Add(btnGo)
  42.  
  43. browserPanel.Controls.Add(panel, 0, 0)
  44. browserPanel.Controls.Add(webBrowser, 1, 0)
  45.  
  46. form.Controls.Add(browserPanel)
  47.  
  48. form.Show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement