PictureBox visible and invisible : PictureBox « GUI Windows Form « C# / C Sharp

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. XML
25. XML LINQ
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorial
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / C Sharp » GUI Windows Form » PictureBoxScreenshots 
PictureBox visible and invisible
PictureBox visible and invisible

using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class ListText : Form {
 
  private Button choose = new Button();
  private ListBox animalList = new ListBox( );
  private ListBox things = new ListBox( );
  private TextBox text = new TextBox( );
  private PictureBox picture = new PictureBox();
  private PictureBox photo = new PictureBox();
  private CheckBox show = new CheckBox();
  private CheckBox author = new CheckBox();
 
  private Bitmap moon = new Bitmap("winter.jpg");
 
  public ListText( ) {
    Text = "List Text";
    choose.Text = "Choose";
    show.Text = "Show a bitmap";
    author.Text = "Show another bitmap";
 
    Size = new Size(400300);
    choose.Size = new Size(100,20);
    text.Size = new Size(150,50);
    photo.Size = new Size(100,100);
 
    choose.Location = new Point(20,30);
    animalList.Location = new Point(30 + choose.Width, 30);
    things.Location = new Point(40 + choose.Width + animalList.Width, 30);
    text.Location = new Point(20150);
    photo.Location = new Point(40 + text.Width, 150);
    picture.Location = new Point(60 + text.Width + photo.Width, 150);
    show.Location = new Point(20,70);
    author.Location = new Point(20,110);
 
    animalList.SelectionMode = SelectionMode.MultiSimple; 
    things.SelectionMode = SelectionMode.One;
    text.Multiline = true;                             
    picture.Image = (Image)moon;                       
    picture.Visible = false;     
    photo.Image = Image.FromFile("winter.jpg");
    photo.Visible = false;
    BackColor = Color.White;
    choose.BackColor = Color.Pink;
 
    animalList.Items.Add("A");
    animalList.Items.Add("B");
    animalList.Items.Add("C");
    animalList.Items.Add("D");
    animalList.Items.Add("E");
    things.Items.Add("1");
    things.Items.Add("2");
    things.Items.Add("3");
    things.Items.Add("4");
 
    Controls.Add(animalList);
    Controls.Add(things);
    Controls.Add(choose);
    Controls.Add(text);
    Controls.Add(picture);
    Controls.Add(show);
    Controls.Add(author);
    Controls.Add(photo);
 
    choose.Click += new EventHandler(Choose_Click);
    things.SelectedIndexChanged += new EventHandler(Things_Changed);
    show.CheckedChanged += new EventHandler(Picture_Changed);
    author.CheckedChanged += new EventHandler(Photo_Changed);
  }
 
  protected void Choose_Click(object sender, EventArgs e) {
    for(int i = 0; i < animalList.SelectedItems.Count; i++){
      Console.WriteLine(animalList.SelectedItems[i].ToString());
    }

  }
 
  protected void Things_Changed(object sender, EventArgs e) {
    text.Text = "You selected " + things.SelectedItem;
  }
 
  protected void Picture_Changed(Object sender, EventArgs e) {
    if (show.Checked)
      picture.Visible = true;
    else
      picture.Visible = false;
    Invalidate();
  }
 
  protected void Photo_Changed(Object sender, EventArgs e) {
    if (author.Checked)
      photo.Visible = true;
    else
      photo.Visible = false;
    Invalidate();
  }
  static void Main() {
     Application.Run(new ListText());
  }
}

           
       
Related examples in the same category
1. PictureBox Click eventPictureBox Click event
2. PictureBox Scroll Text
3. Load image to ImageBoxLoad image to ImageBox
4. PictureBox DemoPictureBox Demo
5. SizeMode in PictureBox
6. Subclass PictureBox
7. Dragging ImagesDragging Images
www___.___ja__v_a_2__s_.__co__m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.