CIS 338: Images on Forms - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

CIS 338: Images on Forms

Description:

stores all images in one place for use in an application, regardless of where installed. can use these images with other controls, such as a Toolbar ... – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 10
Provided by: CBA
Category:
Tags: cis | forms | images

less

Transcript and Presenter's Notes

Title: CIS 338: Images on Forms


1
CIS 338 Images on Forms
  • Dr. Ralph D. Westfall
  • May, 2009

2
Common Controls
  • controls that are also used in Microsoft
    applications, e.g.
  • ImageList - to hold icon images and other images
    used in Windows applications
  • ListView - to display lists, such as file lists
    in file dialog boxes
  • ProgressBar - to show how much has been completed
    e.g., a download

3
VB Collections
  • VB uses "collections" to store common controls
    and many other items
  • e.g., fields in a recordset
  • collection group of objects or properties
  • somewhat like an array, but can be accessed by
    key (name), or index number
  • lstImg.ListImages("car").Picture
  • lstImg.ListImages(2).Picture

4
ImageList Control
  • stores images to use with other controls
  • stores all images in one place for use in an
    application, regardless of where installed
  • can use these images with other controls, such as
    a Toolbar
  • can use code to add images to list or change
    their order
  • can use its key or index value to get items
  • being phased out but still can use in code for
    compatibility with older applications

5
Setting Up an ImageList
  • drag ImageList control onto form (may need to
    Reset Toolbox to see it)
  • right click control, select PropertiesImages
  • click Add, find common graphics at
  • C\Program Files\Microsoft Visual Studio
    9.0\Common7\VS2008ImageLibrary\1033VS2008ImageLibr
    ary/AnnotationsButtons/bmp_formator link
  • click on each file, click Add again for as many
    as you want, then click OK

6
Using Images Without Code
  • can add an image to form via its Properties (not
    using ImageList)
  • click on form
  • find BackgroundImage property
  • click on ... to browse for image, then click OK
  • if image is smaller than the form, the images
    "tile" like they do on web pages

7
Using Images Without Code - 2
  • can add a PictureBox control, and set its path in
    its BackgroundImage property
  • or use code to load image(s) when needed
  • PictureBox1.Image _
  • Image.FromFile("balloon.bmp")
  • the Image can be resized if the PictureBox's
    SizeMode StretchImage
  • a PictureBox can include other controls, not just
    images (e.g., Button)

8
Using Images Without Code - 3
  • can add a ToolStrip control, and set its Items
    property (Collection)
  • then click on ListBox on ToolStripButton
  • right-click Button
  • now click Import and find an image to put on the
    ToolStripButton
  • VS 2003 notes

9
Using an ImageList with Code
  • Private Sub Form1_Load(etc.
  • ImageList1.Images.Add _ (Image.FromFile("path\be
    any.bmp"))
  • 'can add other images into the ImageList
  • '(but images are not shown yet)
  • PictureBox1.Image ImageList1.Images(0)
  • ToolStrip1.ImageList ImageList1
  • ToolStrip1.Items.Add _
  • ("text", ImageList1.Images.Item(0))
  • notes
Write a Comment
User Comments (0)
About PowerShow.com