home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Tree View and List View / TwoPanelsWithSplitter / TwoPanelsWithSplitter.cs next >
Encoding:
Text File  |  2001-01-15  |  1.5 KB  |  49 lines

  1. //----------------------------------------------------
  2. // TwoPanelsWithSplitter.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class TwoPanelsWithSplitter: Form
  9. {
  10.      public static void Main()
  11.      {
  12.           Application.Run(new TwoPanelsWithSplitter());
  13.      }
  14.      public TwoPanelsWithSplitter()
  15.      {
  16.           Text = "Two Panels with Splitter";
  17.  
  18.           Panel panel1     = new Panel();
  19.           panel1.Parent    = this;
  20.           panel1.Dock      = DockStyle.Fill;
  21.           panel1.BackColor = Color.Lime;
  22.           panel1.Resize   += new EventHandler(PanelOnResize);
  23.           panel1.Paint    += new PaintEventHandler(PanelOnPaint);
  24.  
  25.           Splitter split   = new Splitter();
  26.           split.Parent     = this;
  27.           split.Dock       = DockStyle.Right;
  28.  
  29.           Panel panel2     = new Panel();
  30.           panel2.Parent    = this;
  31.           panel2.Dock      = DockStyle.Right;
  32.           panel2.BackColor = Color.Red;
  33.           panel2.Resize   += new EventHandler(PanelOnResize);
  34.           panel2.Paint    += new PaintEventHandler(PanelOnPaint);
  35.      }
  36.      void PanelOnResize(object obj, EventArgs ea)
  37.      {
  38.           ((Panel) obj).Invalidate();
  39.      }
  40.      void PanelOnPaint(object obj, PaintEventArgs pea)
  41.      {
  42.           Panel    panel = (Panel) obj;
  43.           Graphics grfx  = pea.Graphics;
  44.  
  45.           grfx.DrawEllipse(Pens.Black, 0, 0, 
  46.                            panel.Width - 1, panel.Height - 1);
  47.      }
  48. }
  49.