fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. this.Load += new EventHandler(Form1_Load);
  18. }
  19. Panel panel1;
  20. TreeView treeView1;
  21. Button button1;
  22. void Form1_Load(object sender, EventArgs e)
  23. {
  24. treeView1 = new TreeView();
  25. treeView1.Name = "treeView1";
  26. treeView1.Dock = DockStyle.Fill;
  27. this.Controls.Add(treeView1);
  28.  
  29. panel1 = new Panel();
  30. panel1.Name = "panel1";
  31. panel1.Dock = DockStyle.Bottom;
  32. panel1.Height = 26;
  33. this.Controls.Add(panel1);
  34.  
  35. button1 = new Button();
  36. button1.Name = "button1";
  37. button1.Text = "button1";
  38. panel1.Controls.Add(button1);
  39. this.Set();
  40. this.SizeChanged += new EventHandler(Form1_SizeChanged);
  41. }
  42.  
  43. void Set()
  44. {
  45. int bw = button1.Width / 2;
  46. int bh = button1.Height /2;
  47. int pw = panel1.ClientSize.Width / 2;
  48. int ph = panel1.ClientSize.Height /2;
  49. button1.Location = new Point(pw - bw, ph - bh);
  50. }
  51.  
  52. void Form1_SizeChanged(object sender, EventArgs e)
  53. {
  54. this.Set();
  55. }
  56. }
  57. }
  58.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty