| | |
Get image from resources
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
When I created new project I went to Solution Explorer and in Properties I double clicked on Resources.resx. Here I clicked on Add Resource and Add Existing File. Selected images been added and I can use them for darg&drop on form.
My problem is I need to create sort of rollover effect on pictureBox. PictureBox image property is set to none for start. When I go with mouse over pictureBox I want to upload image from resources. How do I do it?
PS: Any good place with C# tutorials?
My problem is I need to create sort of rollover effect on pictureBox. PictureBox image property is set to none for start. When I go with mouse over pictureBox I want to upload image from resources. How do I do it?
pictureBox.Image = ? ? ? ? ?PS: Any good place with C# tutorials?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
C# on MSDN: http://msdn2.microsoft.com/en-us/vcsharp/default.aspx
C# Syntax (Toggle Plain Text)
pictureBox1.Image = Properties.Resources.[image name];
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
OK no error after that, but once I get mouse over pictureBox image is not uploaded. Did I forgot somethink like Paint? I wish they library system was more like Java API...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
In pictureBox event handler (MouseOver) assign the picturebox.image to the image which in resources. It works!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Mar 2008
Posts: 5
Reputation:
Solved Threads: 1
You have to be a little slow when moving your mouse over the picturebox. If you want precision movement try considering writing code in the MouseEnter, MouseLeave event handlers.
Thanks,
Peter Pollen <advertising url snipped>
Thanks,
Peter Pollen <advertising url snipped>
Last edited by happygeek; Mar 9th, 2008 at 8:07 am. Reason: fake sig, please see the rules
I forgot to attach silly event handler
For anybody who wish to generate 2D array of pictureBoxes on runtime here is code snipped for it
And event listeners
For anybody who wish to generate 2D array of pictureBoxes on runtime here is code snipped for it
C# Syntax (Toggle Plain Text)
for (int x = 0; x < stonePlaced.GetUpperBound(0); x++) { for (int y = 0; y < stonePlaced.GetUpperBound(1); y++) { stonePlaced[x, y] = new PictureBox(); stonePlaced[x, y].Size = new Size(80, 80); stonePlaced[x, y].Location = new Point((80 * x),(80 * y)); stonePlaced[x, y].BackColor = System.Drawing.Color.Transparent; stonePlaced[x, y].MouseHover += new System.EventHandler(this.stonePlaced_MouseHover); stonePlaced[x, y].MouseLeave += new System.EventHandler(this.stonePlaced_MouseLeave); boardPanel.Controls.Add(stonePlaced[x, y]); } }
And event listeners
C# Syntax (Toggle Plain Text)
private void stonePlaced_MouseHover(object sender, EventArgs e) { PictureBox pb; pb = (PictureBox)sender; pb.Image = Properties.Resources.purple; } private void stonePlaced_MouseLeave(object sender, EventArgs e) { PictureBox pb; pb = (PictureBox)sender; pb.Image = null; }
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Javascript random image with assigned/accompanying quote (JavaScript / DHTML / AJAX)
- All You Need for SEO (Search Engine Optimization) - Resources List (Search Engine Optimization)
- Read / Write jpg image using COM+ app (Visual Basic 4 / 5 / 6)
- popup like ask.com has on mouse over the binocular image (HTML and CSS)
- Javascript Video Control Resources (JavaScript / DHTML / AJAX)
- Can I make a Java Image Editing Photshop-like program (Java)
- System Resources drainage with Win 98SE (Windows 95 / 98 / Me)
- recommendations for JavaScript learning resources? (JavaScript / DHTML / AJAX)
- Drag and drop an image (Java)
Other Threads in the C# Forum
- Previous Thread: Gridview Paging Problem.
- Next Thread: DragAndDrop doesn't Move
| Thread Tools | Search this Thread |
.net 2007 access algorithm appportability array barchart bitmap box broadcast c# camera check checkbox client combobox control conversion cs4 csharp custom database datagrid datagridview dataset date datetime degrees development draganddrop drawing encryption enum event eventcloseformc# excel file form format forms function gdi+ handler httpwebrequest image index input install java keypress label list listbox listener listview load mandelbrot math mouseclick mysql operator path photoshop picturebox pixelinversion post programming radians regex remote remoting resolved. richtextbox search security server sleep socket sql statistics stream string table text textbox thread time timer update usercontrol validation view visual visualstudio webbrowser windows winforms wordautomation wpf xml






