1 / 9

CIS 338: Images on Forms

Learn how to use common image controls like ImageList, ListView, and ProgressBar in Visual Basic applications. Discover how to store and manage images effectively, set up ImageList, and work with images without writing extensive code.

bnicholls
Download Presentation

CIS 338: Images on Forms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 Properties>Images>… • click Add, find common graphics at C:\Program Files\Microsoft Visual Studio 9.0\Common7\VS2008ImageLibrary\1033VS2008ImageLibrary/Annotations&Buttons/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 ToolStrip>Button • 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\]beany.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

More Related