Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > changing pictures


Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2003, 02:41 PM
xelonite84 xelonite84 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: manchester
Posts: 305
Default changing pictures


is there a way of when selecting an option from a drop down menu that a picture in a frame will change??

i have a computer program and when the user selects dell i want a picture of the dell comp to appear and same for sony, apple and fujitsu

cheers
Reply With Quote
  #2  
Old 01-20-2003, 02:52 PM
Gamer X's Avatar
Gamer X Gamer X is offline
Senior Contributor
 
Join Date: Jul 2001
Location: /dev/meow
Posts: 1,180
Default

Well, a simple way would be to have something like this in the ComboBox_Click event:
Code:
PictureBox.Picture = LoadPicture(App.Path & "\" & ComboBox.Text & ".bmp")
This would give PictureBox the picture of a bitmap whos name is the selected ComboBox item.

Arigato,
Gamer X
Edit: That \/ works too.
__________________
Webmaster, Senior Programmer, and all the rest at Gamer X Creations (currently offline)

Life would be much easier if I had the source code . . .
Reply With Quote
  #3  
Old 01-20-2003, 02:52 PM
Mikecrosoft's Avatar
Mikecrosoft Mikecrosoft is offline
Mexican Coder
 
Join Date: Jun 2002
Location: Monterrey, N.L., Mexico
Posts: 2,793
Default

You can use an ImageList with your pictures and into the Click Event for the drop down menu put this:

Code:
Private Sub Combo1_Click() Set Picture1.Picture = Image1.ListImage(Combo1.ListIndex + 1).Picture End Sub

You need to add exactly the same number of items into the ImageList and the combo box. Also the order for PC's into the combo is the same for ImageList
__________________
Mikecrosoft.NET
* If I stop to ask I will stop to learn
* Just I know that I don't know nothing
Reply With Quote
  #4  
Old 01-20-2003, 03:15 PM
xelonite84 xelonite84 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: manchester
Posts: 305
Default

could you explain that code to me mike so that i can make the changes i need for it to work properly ?

thx
Reply With Quote
  #5  
Old 01-20-2003, 03:23 PM
Mikecrosoft's Avatar
Mikecrosoft Mikecrosoft is offline
Mexican Coder
 
Join Date: Jun 2002
Location: Monterrey, N.L., Mexico
Posts: 2,793
Default

Yes.

First Add a ImageList with the number images that you wish (PC's pictures).

Second Add the Combobox (drop-down menu) with the same number of PC's in the same order of the ImageList pictures.

Third Add this code in the Click Event for the drop-down menu.

Explanation:

When you click in one Item into Combo1, generates the Click Event, and the ListIndex property of the combo1 is the number of PC clicked. Because ListIndex start the counting in 0 and the ListImages starts in 1, then add 1 to the ListIndex.

Example:

Combo1 items itm # :
- IMB PC 0
-Dell PC 1
-Compaq PC 2

ImageList Images itm #:
-IMB Picture 1
-Dell Picture 2
-Comapq Picture 3

when you click Dell PC ListIndex = 1, and add 1 = 2, this number correspond into ListImages to DellPC.


I hope make sense.
__________________
Mikecrosoft.NET
* If I stop to ask I will stop to learn
* Just I know that I don't know nothing
Reply With Quote
  #6  
Old 01-20-2003, 04:35 PM
xelonite84 xelonite84 is offline
Junior Contributor
 
Join Date: Apr 2003
Location: manchester
Posts: 305
Default

sorry it doesnt really if u cant b bothered dont worry ill spend more time looking at it 2morrow

cheers
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->