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.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# Book
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
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.