Hello!
My problem is exactly as it says in the title :P
My goal is to have couple of items in the listbox and when highlighting one item a image in the picturebox should appear, and so on for each item in the listbox.
I just don't know how to change image depending on selected item in the listbox.
don't know if it's relevant but, my inputs in the listbox is from an arraylist.
If anyone is willing to aid in my needs I would greatly appreciate it!
Thanks in advance
Noobatron Rubbadrools
7 replies to this topic
#1
Posted 19 July 2011 - 09:06 AM
|
|
|
#2
Posted 19 July 2011 - 09:32 AM
Are you having trouble setting an image in the picturebox, detecting when something is selected in the listbox, detecting which item is selected in the listbox, or something else? Without seeing your current code, it is hard to determine where you're stuck.
#3
Posted 19 July 2011 - 09:43 AM
Ahh Sorry, I suck at explaining :P
It's setting a image in the picturebox when selecting a item from the listbox
like this:
*start form
*listbox gets filled with a bunch of names from the arraylist
*when a name is highlighted a picture will appear in the picturebox
something like that :P
I don't blame u if u didn't understand this explanation either and in that case i'll try again by printing :P
It's setting a image in the picturebox when selecting a item from the listbox
like this:
*start form
*listbox gets filled with a bunch of names from the arraylist
*when a name is highlighted a picture will appear in the picturebox
something like that :P
I don't blame u if u didn't understand this explanation either and in that case i'll try again by printing :P
#4
Posted 19 July 2011 - 12:36 PM
I understand what you're trying to do. I don't understand which part of that you're having difficulty with. You've listed three steps. You could be having troubles starting a form, for all I know.
#5
Posted 19 July 2011 - 01:43 PM
The code issue is connecting the highlighted name to a picture that shows in the picturebox.
so when all the names are up in the list, I can press one name and another picture in the picturebox is shown.
Thats how far i've come, I have another class for the Arrays but I figured that isn't the important part atm
so when all the names are up in the list, I can press one name and another picture in the picturebox is shown.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace laxa3._1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ArrayList nameList = new ArrayList();
Namn namn1 = new Namn("John");
Namn namn2 = new Namn("Katy");
Namn namn3 = new Namn("Dan");
nameList.Add(namn1);
nameList.Add(namn2);
nameList.Add(namn3);
foreach (Namn obj in nameList)
listBox1.Items.Add(obj.nNamn);
/* foreach (Namn obj in nameList)
pictureBox1.Load("C:\\Users\\Arrian\\Documents\\Visual Studio 2010\\Projects\\Assignment3.1\\Assignment3.1\\bin\\" + n ".jpg");
if (listBox1.SelectedIndex = )
{
pictureBox1.Load("C:\\Users\\Arrian\\Documents\\Visual Studio 2010\\Projects\\Assignment3.1\\Assignment3.1\\bin\\Katy.jpg");
pictureBox1.Load("C:\\Users\\Arrian\\Documents\\Visual Studio 2010\\Projects\\Assignment3.1\\Assignment3.1\\bin\\Katy.jpg");
}
*/
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
Thats how far i've come, I have another class for the Arrays but I figured that isn't the important part atm
#6
Posted 19 July 2011 - 03:30 PM
#7
Posted 19 July 2011 - 03:59 PM
Thanks! I feel kinda stupid for not figuring this out myself but it's like when u do a puzzlebox and can't put the last pieces together... Sometimes all you need is a fresh pair of eyes ;)
#8
Posted 19 July 2011 - 05:38 PM
No problem. MSDN + Google rocks.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









