Display message in StatusBar

   


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form
{
  private System.Windows.Forms.GroupBox groupBox1;
  private System.Windows.Forms.ComboBox lstFonts;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.StatusStrip statusBar;
  private System.Windows.Forms.ToolStripStatusLabel statusLabel;

  public Form1() {
        InitializeComponent();
    System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
    foreach (FontFamily family in fonts.Families)
    {
      lstFonts.Items.Add(family.Name);
    }
  }

  private void lstFonts_SelectedIndexChanged(object sender, EventArgs e)
  {
        this.Invalidate();
  }

  private void Form1_Paint(object sender, PaintEventArgs e)
  {
    if (lstFonts.SelectedIndex != -1)
    {
            e.Graphics.DrawString(lstFonts.Text, new Font(lstFonts.Text, 50), Brushes.Black, 10, 50);
            statusBar.Items[0].Text = lstFonts.Text;
    }
  }

  private void InitializeComponent()
  {
    this.groupBox1 = new System.Windows.Forms.GroupBox();
    this.lstFonts = new System.Windows.Forms.ComboBox();
    this.label1 = new System.Windows.Forms.Label();
    this.statusBar = new System.Windows.Forms.StatusStrip();
    this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel();
    this.groupBox1.SuspendLayout();
    this.statusBar.SuspendLayout();
    this.SuspendLayout();
    // 
    // groupBox1
    // 
    this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
          | System.Windows.Forms.AnchorStyles.Right)));
    this.groupBox1.Controls.Add(this.lstFonts);
    this.groupBox1.Controls.Add(this.label1);
    this.groupBox1.Location = new System.Drawing.Point(7, 0);
    this.groupBox1.Name = "groupBox1";
    this.groupBox1.Size = new System.Drawing.Size(497, 40);
    this.groupBox1.TabIndex = 1;
    this.groupBox1.TabStop = false;
    // 
    // lstFonts
    // 
    this.lstFonts.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    this.lstFonts.DropDownWidth = 340;
    this.lstFonts.FormattingEnabled = true;
    this.lstFonts.Location = new System.Drawing.Point(100, 12);
    this.lstFonts.Name = "lstFonts";
    this.lstFonts.Size = new System.Drawing.Size(340, 21);
    this.lstFonts.TabIndex = 1;
    this.lstFonts.SelectedIndexChanged += new System.EventHandler(this.lstFonts_SelectedIndexChanged);
    // 
    // label1
    // 
    this.label1.Location = new System.Drawing.Point(12, 16);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(80, 12);
    this.label1.TabIndex = 0;
    this.label1.Text = "Choose Font:";
    // 
    // statusBar
    // 
    this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.statusLabel});
    this.statusBar.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Table;
    this.statusBar.Location = new System.Drawing.Point(0, 155);
    this.statusBar.Name = "statusBar";
    this.statusBar.Size = new System.Drawing.Size(516, 22);
    this.statusBar.TabIndex = 2;
    this.statusBar.Text = "statusStrip1";
    // 
    // statusLabel
    // 
    this.statusLabel.Name = "statusLabel";
    // 
    // Form1
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(516, 177);
    this.Controls.Add(this.groupBox1);
    this.Controls.Add(this.statusBar);
    this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.Text = "Font Viewer";
    this.Load += new System.EventHandler(this.Form1_Load);
    this.groupBox1.ResumeLayout(false);
    this.statusBar.ResumeLayout(false);
    this.ResumeLayout(false);
    this.PerformLayout();

  }

  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }

}


           
          


Use Label as status bar


   


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form
{
    private System.Windows.Forms.Label lblCount;
    List<Rectangle> squares = new List<Rectangle>();

  public Form1() {
        InitializeComponent();
        
  }
    private void NonOptimizedSquares_Paint(object sender, PaintEventArgs e)
    {
      Pen pen = new Pen(Color.Red, 10);
      foreach (Rectangle square in squares) {
        e.Graphics.DrawRectangle(pen, square);
      }
      pen.Dispose();
      lblCount.Text = " " + squares.Count.ToString() + " squares"; 
    }

    private void NonOptimizedSquares_MouseDown(object sender, MouseEventArgs e)
    {
      if (e.Button == MouseButtons.Left)
      {
        Rectangle square = new Rectangle(e.X, e.Y, 20, 20);
        squares.Add(square);
                square.Inflate(1, 1);
                Invalidate(square);
      } 
    }

    private void InitializeComponent()
    {
      this.lblCount = new System.Windows.Forms.Label();
      this.SuspendLayout();
      // 
      // lblCount
      // 
      this.lblCount.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
      this.lblCount.Dock = System.Windows.Forms.DockStyle.Bottom;
      this.lblCount.Location = new System.Drawing.Point(0, 251);
      this.lblCount.Name = "lblCount";
      this.lblCount.Padding = new System.Windows.Forms.Padding(2);
      this.lblCount.Size = new System.Drawing.Size(299, 21);
      this.lblCount.TabIndex = 0;
      // 
      // NonOptimizedSquares
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(299, 272);
      this.Controls.Add(this.lblCount);
      this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.Name = "NonOptimizedSquares";
      this.Text = "NonOptimizedSquares";
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.NonOptimizedSquares_Paint);
      this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.NonOptimizedSquares_MouseDown);
      this.ResumeLayout(false);

    }

  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }

}


           
          


Split Three Across

   
 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class SplitThreeAcross: Form
{
     public static void Main()
     {
          Application.Run(new SplitThreeAcross());
     }
     public SplitThreeAcross()
     {
          Panel panel1     = new Panel();
          panel1.Parent    = this;
          panel1.Dock      = DockStyle.Fill;
          panel1.BackColor = Color.Cyan;
          panel1.Resize   += new EventHandler(PanelOnResize);
          panel1.Paint    += new PaintEventHandler(PanelOnPaint);
   
          Splitter split1  = new Splitter();
          split1.Parent    = this;
          split1.Dock      = DockStyle.Left;
   
          Panel panel2     = new Panel();
          panel2.Parent    = this;
          panel2.Dock      = DockStyle.Left;
          panel2.BackColor = Color.Lime;
          panel2.Resize   += new EventHandler(PanelOnResize);
          panel2.Paint    += new PaintEventHandler(PanelOnPaint);
   
          Splitter split2  = new Splitter();
          split2.Parent    = this;
          split2.Dock      = DockStyle.Right;
   
          Panel panel3     = new Panel();
          panel3.Parent    = this;
          panel3.Dock      = DockStyle.Right;
          panel3.BackColor = Color.Red;
          panel3.Resize   += new EventHandler(PanelOnResize);
          panel3.Paint    += new PaintEventHandler(PanelOnPaint);
   
          panel1.Width = 
          panel2.Width = 
          panel3.Width = ClientSize.Width / 3;
     }
     void PanelOnResize(object obj, EventArgs ea)
     {
          ((Panel) obj).Invalidate();
     }
     void PanelOnPaint(object obj, PaintEventArgs pea)
     {
          Panel    panel = (Panel) obj;
          Graphics grfx  = pea.Graphics;
   
          grfx.DrawEllipse(Pens.Black, 0, 0, 
                           panel.Width - 1, panel.Height - 1);
     }
}

    


ScrollBars Demo

/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury,
Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ScrollBars
{
///

/// Summary description for ScrollBars.
///

public class ScrollBars : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.VScrollBar vScrollBar1;
///

/// Required designer variable.
///

int counter=0;
private System.Windows.Forms.Label label1;
private System.ComponentModel.Container components = null;

public ScrollBars()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///

/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///

/// Required method for Designer support – do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.textBox1.ForeColor = System.Drawing.Color.Transparent;
this.textBox1.Location = new System.Drawing.Point(24, 56);
this.textBox1.Multiline = true;
this.textBox1.Name = “textBox1”;
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(144, 32);
this.textBox1.TabIndex = 4;
this.textBox1.Text = “”;
this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// vScrollBar1
//
this.vScrollBar1.Location = new System.Drawing.Point(168, 56);
this.vScrollBar1.Name = “vScrollBar1”;
this.vScrollBar1.Size = new System.Drawing.Size(16, 32);
this.vScrollBar1.TabIndex = 7;
this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 16);
this.label1.Name = “label1”;
this.label1.Size = new System.Drawing.Size(192, 16);
this.label1.TabIndex = 6;
this.label1.Text = “Numeric Scolling using VScroll Bars”;
//
// ScrollBars
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(208, 109);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1,
this.vScrollBar1,
this.textBox1});
this.Name = “ScrollBars”;
this.Text = “Numeric Scroll”;
this.Load += new System.EventHandler(this.ScrollBars_Load);
this.ResumeLayout(false);

}
#endregion

///

/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new ScrollBars());
}

private void textBox1_TextChanged(object sender, System.EventArgs e)
{
}

private void ScrollBars_Load(object sender, System.EventArgs e)
{
// Set the maximum range for the scrollbar
vScrollBar1.Maximum = 100;
// Set the minimum range for the scrollbar
vScrollBar1.Minimum = 0 ;

// Set the SmallChange factor
vScrollBar1.SmallChange = 1;

}

private void vScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
{
// Check if the increment is Small
if ( e.Type == ScrollEventType.Last )
counter = 100 ;
else
// Check if the scroll is moved to minimum pos
if ( e.Type == ScrollEventType.First)
counter = 0 ;
else
// Check if the scroll is moved small distance
if ( e.Type == ScrollEventType.SmallDecrement )
counter — ;
else
// Check if the scroll is moved small distance
if ( e.Type == ScrollEventType.SmallIncrement )
{
counter++;
MessageBox.Show(“Small increment”);
}
else
// Check if the scroll is moved large distance
if ( e.Type == ScrollEventType.LargeDecrement )
counter-=5;
else
// Check if the scroll is moved large distance
if ( e.Type == ScrollEventType.LargeIncrement )
{
MessageBox.Show(“Large increment”);
counter+=5;
}
else
// Check if the scroll is moved to the Min position
if ( e.Type == ScrollEventType.First )
counter = 0 ;
else
// Check if the scroll to the Max position
if ( e.Type == ScrollEventType.Last)
counter = 100 ;

Console.WriteLine(e.NewValue+”
“);
// Check if the scroll is moved large distance
if ( counter > 100 ) counter = 100 ;
if ( counter < 0 ) counter = 0 ; textBox1.Text = counter.ToString() ; } } } [/csharp]

VScrollBar ValueChanged

using System;
using System.Drawing;
using System.Windows.Forms;

class ColorScroll: Form
{
Panel panel;
Label[] alabelName = new Label[3];
Label[] alabelValue = new Label[3];
VScrollBar[] avscroll = new VScrollBar[3];

public static void Main()
{
Application.Run(new ColorScroll());
}
public ColorScroll()
{
Color[] acolor = { Color.Red, Color.Green, Color.Blue };

panel = new Panel();
panel.Parent = this;
panel.Location = new Point(0, 0);
panel.BackColor = Color.White;

for (int i = 0; i < 3; i++) { alabelName[i] = new Label(); alabelName[i].Parent = panel; alabelName[i].ForeColor = acolor[i]; alabelName[i].Text = "&" + acolor[i].ToKnownColor(); alabelName[i].TextAlign = ContentAlignment.MiddleCenter; avscroll[i] = new VScrollBar(); avscroll[i].Parent = panel; avscroll[i].SmallChange = 1; avscroll[i].LargeChange = 16; avscroll[i].Minimum = 0; avscroll[i].Maximum = 255 + avscroll[i].LargeChange - 1; avscroll[i].ValueChanged += new EventHandler(ScrollOnValueChanged); avscroll[i].TabStop = true; alabelValue[i] = new Label(); alabelValue[i].Parent = panel; alabelValue[i].TextAlign = ContentAlignment.MiddleCenter; } Color color = BackColor; avscroll[0].Value = color.R; // Generates ValueChanged event avscroll[1].Value = color.G; avscroll[2].Value = color.B; OnResize(EventArgs.Empty); } protected override void OnResize(EventArgs ea) { base.OnResize(ea); int cx = ClientSize.Width; int cy = ClientSize.Height; int cyFont = Font.Height; panel.Size = new Size(cx / 2, cy); for (int i = 0; i < 3; i++) { alabelName[i].Location = new Point(i * cx / 6, cyFont / 2); alabelName[i].Size = new Size(cx / 6, cyFont); avscroll[i].Location = new Point((4 * i + 1) * cx / 24, 2 * cyFont); avscroll[i].Size = new Size(cx / 12, cy - 4 * cyFont); alabelValue[i].Location = new Point(i * cx / 6, cy - 3 * cyFont / 2); alabelValue[i].Size = new Size(cx / 6, cyFont); } } void ScrollOnValueChanged(Object obj, EventArgs ea) { for (int i = 0; i < 3; i++) if((VScrollBar) obj == avscroll[i]) alabelValue[i].Text = avscroll[i].Value.ToString(); BackColor = Color.FromArgb(avscroll[0].Value, avscroll[1].Value, avscroll[2].Value); } } [/csharp]

Scroll event

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : System.Windows.Forms.Form {
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.VScrollBar vScrollBar1;
int counter = 0;
private System.Windows.Forms.Label label1;
public Form1() {
this.textBox1 = new System.Windows.Forms.TextBox();
this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();

this.textBox1.Font = new System.Drawing.Font(“Microsoft Sans Serif”, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.textBox1.ForeColor = System.Drawing.Color.Transparent;
this.textBox1.Location = new System.Drawing.Point(24, 56);
this.textBox1.Multiline = true;
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(144, 32);
this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;

this.vScrollBar1.Location = new System.Drawing.Point(168, 56);
this.vScrollBar1.Size = new System.Drawing.Size(16, 32);
this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll);

this.label1.Location = new System.Drawing.Point(8, 16);
this.label1.Size = new System.Drawing.Size(192, 16);
this.label1.Text = “Numeric Scolling using VScroll Bars”;

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(208, 109);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1,
this.vScrollBar1,
this.textBox1});
this.Text = “Numeric Scroll”;
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
[STAThread]
static void Main() {
Application.Run(new Form1());
}

private void textBox1_TextChanged(object sender, System.EventArgs e) {
}

private void Form1_Load(object sender, System.EventArgs e) {
vScrollBar1.Maximum = 100;
vScrollBar1.Minimum = 0;
vScrollBar1.SmallChange = 1;

}

private void vScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) {
if (e.Type == ScrollEventType.Last)
counter = 100;
if (e.Type == ScrollEventType.First)
counter = 0;
if (e.Type == ScrollEventType.SmallDecrement)
counter–;
if (e.Type == ScrollEventType.SmallIncrement) {
counter++;
}
if (e.Type == ScrollEventType.LargeDecrement)
counter -= 5;
if (e.Type == ScrollEventType.LargeIncrement) {
counter += 5;
}
if (e.Type == ScrollEventType.First)
counter = 0;
if (e.Type == ScrollEventType.Last)
counter = 100;

Console.WriteLine(e.NewValue + ”
“);
if (counter > 100) counter = 100;
if (counter < 0) counter = 0; Console.WriteLine(counter.ToString()); } } [/csharp]

HTML Split Window



   

/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald

Publisher: Apress
ISBN: 1590590457
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;

namespace HTMLSplitWindow
{
  /// <summary>
  /// Summary description for HTMLSplitWindow.
  /// </summary>
  public class HTMLSplitWindow : System.Windows.Forms.Form
  {
    internal System.Windows.Forms.Panel Panel3;
    internal System.Windows.Forms.TextBox TextBox1;
    internal System.Windows.Forms.Splitter Splitter1;
    internal System.Windows.Forms.Panel Panel2;
    private AxSHDocVw.AxWebBrowser AxWebBrowser2;
    internal System.Windows.Forms.Splitter Splitter2;
    internal System.Windows.Forms.Panel pnlShow;
    internal System.Windows.Forms.Button cmdShow;
    internal System.Windows.Forms.Panel pnlFileList;
    internal System.Windows.Forms.Button cmdHide;
    internal System.Windows.Forms.ListView ListView1;
    internal System.Windows.Forms.ColumnHeader ColumnHeader1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

    public HTMLSplitWindow()
    {
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
      if( disposing )
      {
        if (components != null) 
        {
          components.Dispose();
        }
      }
      base.Dispose( disposing );
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(HTMLSplitWindow));
      this.Panel3 = new System.Windows.Forms.Panel();
      this.TextBox1 = new System.Windows.Forms.TextBox();
      this.Splitter1 = new System.Windows.Forms.Splitter();
      this.Panel2 = new System.Windows.Forms.Panel();
      this.AxWebBrowser2 = new AxSHDocVw.AxWebBrowser();
      this.Splitter2 = new System.Windows.Forms.Splitter();
      this.pnlShow = new System.Windows.Forms.Panel();
      this.cmdShow = new System.Windows.Forms.Button();
      this.pnlFileList = new System.Windows.Forms.Panel();
      this.cmdHide = new System.Windows.Forms.Button();
      this.ListView1 = new System.Windows.Forms.ListView();
      this.ColumnHeader1 = new System.Windows.Forms.ColumnHeader();
      this.Panel3.SuspendLayout();
      this.Panel2.SuspendLayout();
      ((System.ComponentModel.ISupportInitialize)(this.AxWebBrowser2)).BeginInit();
      this.pnlShow.SuspendLayout();
      this.pnlFileList.SuspendLayout();
      this.SuspendLayout();
      // 
      // Panel3
      // 
      this.Panel3.Controls.AddRange(new System.Windows.Forms.Control[] {
                                         this.TextBox1});
      this.Panel3.Dock = System.Windows.Forms.DockStyle.Fill;
      this.Panel3.Location = new System.Drawing.Point(204, 131);
      this.Panel3.Name = "Panel3";
      this.Panel3.Size = new System.Drawing.Size(239, 154);
      this.Panel3.TabIndex = 28;
      // 
      // TextBox1
      // 
      this.TextBox1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
        | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right);
      this.TextBox1.Multiline = true;
      this.TextBox1.Name = "TextBox1";
      this.TextBox1.ReadOnly = true;
      this.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
      this.TextBox1.Size = new System.Drawing.Size(240, 153);
      this.TextBox1.TabIndex = 0;
      this.TextBox1.Text = "";
      // 
      // Splitter1
      // 
      this.Splitter1.Dock = System.Windows.Forms.DockStyle.Top;
      this.Splitter1.Location = new System.Drawing.Point(204, 128);
      this.Splitter1.Name = "Splitter1";
      this.Splitter1.Size = new System.Drawing.Size(239, 3);
      this.Splitter1.TabIndex = 27;
      this.Splitter1.TabStop = false;
      // 
      // Panel2
      // 
      this.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
      this.Panel2.Controls.AddRange(new System.Windows.Forms.Control[] {
                                         this.AxWebBrowser2});
      this.Panel2.Dock = System.Windows.Forms.DockStyle.Top;
      this.Panel2.Location = new System.Drawing.Point(204, 5);
      this.Panel2.Name = "Panel2";
      this.Panel2.Size = new System.Drawing.Size(239, 123);
      this.Panel2.TabIndex = 26;
      // 
      // AxWebBrowser2
      // 
      this.AxWebBrowser2.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
        | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right);
      this.AxWebBrowser2.ContainingControl = this;
      this.AxWebBrowser2.Enabled = true;
      this.AxWebBrowser2.Location = new System.Drawing.Point(-4, 0);
      this.AxWebBrowser2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("AxWebBrowser2.OcxState")));
      this.AxWebBrowser2.Size = new System.Drawing.Size(240, 120);
      this.AxWebBrowser2.TabIndex = 0;
      // 
      // Splitter2
      // 
      this.Splitter2.Location = new System.Drawing.Point(201, 5);
      this.Splitter2.Name = "Splitter2";
      this.Splitter2.Size = new System.Drawing.Size(3, 280);
      this.Splitter2.TabIndex = 25;
      this.Splitter2.TabStop = false;
      // 
      // pnlShow
      // 
      this.pnlShow.Controls.AddRange(new System.Windows.Forms.Control[] {
                                          this.cmdShow});
      this.pnlShow.Dock = System.Windows.Forms.DockStyle.Left;
      this.pnlShow.Location = new System.Drawing.Point(181, 5);
      this.pnlShow.Name = "pnlShow";
      this.pnlShow.Size = new System.Drawing.Size(20, 280);
      this.pnlShow.TabIndex = 24;
      this.pnlShow.Visible = false;
      // 
      // cmdShow
      // 
      this.cmdShow.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
        | System.Windows.Forms.AnchorStyles.Left);
      this.cmdShow.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.cmdShow.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.cmdShow.Name = "cmdShow";
      this.cmdShow.Size = new System.Drawing.Size(16, 280);
      this.cmdShow.TabIndex = 17;
      this.cmdShow.Text = ">";
      this.cmdShow.Click += new System.EventHandler(this.cmdShow_Click);
      // 
      // pnlFileList
      // 
      this.pnlFileList.Controls.AddRange(new System.Windows.Forms.Control[] {
                                            this.cmdHide,
                                            this.ListView1});
      this.pnlFileList.Dock = System.Windows.Forms.DockStyle.Left;
      this.pnlFileList.Location = new System.Drawing.Point(5, 5);
      this.pnlFileList.Name = "pnlFileList";
      this.pnlFileList.Size = new System.Drawing.Size(176, 280);
      this.pnlFileList.TabIndex = 23;
      // 
      // cmdHide
      // 
      this.cmdHide.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right);
      this.cmdHide.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.cmdHide.Location = new System.Drawing.Point(0, 260);
      this.cmdHide.Name = "cmdHide";
      this.cmdHide.Size = new System.Drawing.Size(172, 20);
      this.cmdHide.TabIndex = 1;
      this.cmdHide.Text = "<< Hide";
      this.cmdHide.Click += new System.EventHandler(this.cmdHide_Click);
      // 
      // ListView1
      // 
      this.ListView1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
        | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right);
      this.ListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader&#91;&#93; {
                                            this.ColumnHeader1});
      this.ListView1.Name = "ListView1";
      this.ListView1.Size = new System.Drawing.Size(172, 256);
      this.ListView1.TabIndex = 0;
      this.ListView1.View = System.Windows.Forms.View.Details;
      this.ListView1.SelectedIndexChanged += new System.EventHandler(this.ListView1_SelectedIndexChanged);
      // 
      // ColumnHeader1
      // 
      this.ColumnHeader1.Text = "File";
      this.ColumnHeader1.Width = 99;
      // 
      // HTMLSplitWindow
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
      this.ClientSize = new System.Drawing.Size(448, 290);
      this.Controls.AddRange(new System.Windows.Forms.Control&#91;&#93; {
                                      this.Panel3,
                                      this.Splitter1,
                                      this.Panel2,
                                      this.Splitter2,
                                      this.pnlShow,
                                      this.pnlFileList});
      this.DockPadding.All = 5;
      this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.Name = "HTMLSplitWindow";
      this.Text = "HTML Split";
      this.Load += new System.EventHandler(this.HTMLSplitWindow_Load);
      this.Panel3.ResumeLayout(false);
      this.Panel2.ResumeLayout(false);
      ((System.ComponentModel.ISupportInitialize)(this.AxWebBrowser2)).EndInit();
      this.pnlShow.ResumeLayout(false);
      this.pnlFileList.ResumeLayout(false);
      this.ResumeLayout(false);

    }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
      Application.Run(new HTMLSplitWindow());
    }

    private void cmdHide_Click(object sender, System.EventArgs e)
    {
      pnlFileList.Visible = false;
      pnlShow.Visible = true;
    }

    private void cmdShow_Click(object sender, System.EventArgs e)
    {
      pnlFileList.Visible = true;
      pnlShow.Visible = false;
    }

    private void HTMLSplitWindow_Load(object sender, System.EventArgs e)
    {
      DirectoryInfo d = new DirectoryInfo(Application.StartupPath + @"....view");
      foreach (FileInfo f in d.GetFiles())
      {
        ListView1.Items.Add(f.Name);
      }

    }

    private void ListView1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
      try
      {
        // Construct the objects required for the Navigate2 method call.
        // C# does not support optional parameters.
        string urlText = @"C:Program FilesMicrosoft Visual Studio .NETFrameworkSDKSamples" + ListView1.SelectedItems[0].Text;
        object url = urlText;
        int emptyInt = 0;
        object empty = emptyInt;

        AxWebBrowser2.Navigate2(ref url, ref empty, ref empty, ref empty, ref empty);
        StreamReader r = File.OpenText(@"C:Program FilesMicrosoft Visual Studio .NETFrameworkSDKSamples" + ListView1.SelectedItems[0].Text);
        TextBox1.Text = r.ReadToEnd();
      }
      catch
      {
      }

    }
  }
}



           
          


HTMLSplitWindow.zip( 181 k)