PictureBox Click event : PictureBox « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » PictureBoxScreenshots 
PictureBox Click event
PictureBox Click event


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

   public class PictureBoxTest : System.Windows.Forms.Form
   {
      private System.Windows.Forms.PictureBox imagePictureBox;
      private System.Windows.Forms.Label promptLabel;

      public PictureBoxTest()
      {
         InitializeComponent();
      }

      private void InitializeComponent()
      {
         this.promptLabel = new System.Windows.Forms.Label();
         this.imagePictureBox = new System.Windows.Forms.PictureBox();
         this.SuspendLayout();

         this.promptLabel.Font = new System.Drawing.Font("Microsoft Sans Serif"9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.promptLabel.Location = new System.Drawing.Point(228);
         this.promptLabel.Name = "promptLabel";
         this.promptLabel.Size = new System.Drawing.Size(12456);
         this.promptLabel.TabIndex = 0;
         this.promptLabel.Text = "Click On PictureBox to View Images";
         this.promptLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

         this.imagePictureBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
         this.imagePictureBox.Location = new System.Drawing.Point(3472);
         this.imagePictureBox.Name = "imagePictureBox";
         this.imagePictureBox.Size = new System.Drawing.Size(100100);
         this.imagePictureBox.TabIndex = 1;
         this.imagePictureBox.TabStop = false;

         this.imagePictureBox.Click += new System.EventHandler(this.imagePictureBox_Click );

         this.AutoScaleBaseSize = new System.Drawing.Size(513);
         this.ClientSize = new System.Drawing.Size(168189);
         this.Controls.AddRange(new System.Windows.Forms.Control[] {this.imagePictureBox,
                                                                      this.promptLabel});
         this.Text = "PictureBoxTest";
         this.ResumeLayout(false);

      }
      [STAThread]
      static void Main() 
      {
         Application.Runnew PictureBoxTest() );
      }

      private void imagePictureBox_Click(object sender, System.EventArgs e )
      {
         imagePictureBox.Image = Image.FromFile(Directory.GetCurrentDirectory() "\\winter.jpg" );
      }

   }



           
       
Related examples in the same category
1.PictureBox Scroll Text
2.PictureBox visible and invisiblePictureBox visible and invisible
3.Load image to ImageBoxLoad image to ImageBox
4.PictureBox DemoPictureBox Demo
5.SizeMode in PictureBox
6.Subclass PictureBox
7.Dragging ImagesDragging Images
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.