I am currently working on a program to teach myself C#. In it, a person is "throwing" meatloaf at a picture of Hilary Clinton's head. (long story). I've created the picturebox containing Hilary's head from the toolbox, but I created my meatloaf pictureboxes from code. I have right clicked on Hilary's picture and selected "Send to Back", and used the Meatloaf.BringToFront();, but for some reason, the meatloaf always goes behind Hilary's head, making it hidden.
The code I used to set up the Meatloaf pictureboxes is
(global)
public PictureBox[] picNewMeatLoaf = new PictureBox[20];
(In a FormLoad)
for (int j = 1; j <= 19; j++)
{
picNewMeatLoaf[j] = new PictureBox();
picNewMeatLoaf[j].BringToFront();
}
__________________________________
(In a AddMeatLoaf() procedure)
this.SuspendLayout();
picNewMeatLoaf[i].Location = new Point(0, 0);
picNewMeatLoaf[i].Size = new Size(75, 25);
picNewMeatLoaf[i].BringToFront();
picNewMeatLoaf[i].Image = this.picMeatLoaf.Image;
this.Controls.AddRange(new Control[] { picNewMeatLoaf[i] });
this.ResumeLayout();
___________________________________
(in a timer)
for (int j = 1; j < 20; j++)
{
if (this.picNewMeatLoaf[j].Top < 305 & picNewMeatLoaf[j].Left < 693) //305 is the ground level, 693 is the spot on Hilary's face to stop
{
this.picNewMeatLoaf[j].Top = picNewMeatLoaf[j].Top + 1;
this.picNewMeatLoaf[j].Left = picNewMeatLoaf[j].Left + MeatLoafSpeed[j];
}
That is just the code related to the MeatLoaf picturebox, so obviously there is a lot more code. Note, this is my first real attempt at a program with C#, so the code isn't going to be the best.
Does anyone see what I'm doing wrong or have any suggestions? I'm all out of ideas, and I'd rather not have to just add it into the form1's background image. If you need anymore code or information, just let me know.
Oh, and if anyone has any ideas on how to make parts of picture boxes transparent, meaning they show the objects behind it, it would be VERY appreciated.
I'd concur too, as an informed enthusiast I'd find it a good deal, but your average Joe just wants cheap as possible and it's hard to beat Amazon or Ebay builds for that.
An Air India plane with 242 people on board crashed Thursday near a major international airport in the western Indian city of Ahmedabad, the airline and the country's government said.
https://www.nbcnews.com/world/asia/air-india-plane-crashes-indias-ahmedabad-airport-rcna212545
NTLite 2025.06.10473 by Razvan Serea
NTLite is a Windows configuration tool that allows you to modify your existing Windows install or an image yet to be deployed, remove Windows components, configure and integrate, speed up the Windows deployment process. Reduce Windows footprint on your RAM and storage drive memory. Remove components of your choice, guarded by compatibility safety mechanisms, which speed up finding that sweet spot. Windows Unattended feature support, providing many commonly used options on a single page for easy setup.
Easily integrate a single or multiple drivers, update or language packages. Package integration features smart sorting, enabling you to seamlessly add packages for integration and the tool will apply them in the appropriate order, keeping hotfix compatibility in check.
One of the important new features of NTLite (compared to its predecessors) is the ability to modify an already installed the operating system, by removing unnecessary components.
Supports Windows 11, 10, 8.1 and 7, x86 and x64, live and image. Server editions of the same versions, excluding support for component removals and feature configuration. ARM64 image support in the alpha stage. Does not support Checked/Debug, Embedded, IoT editions, nor Vista or XP. NTLite 2025.06.10473 changelog: Upgrade UI: Text size now set as host, more readable on some systems
Post-setup: Loading progress improvement for the 99% delay
Components: ‘Snipping tool’ compatibility option
UI-Translation: Thanks for Romanian (Coman)
Fix Updates: Parallel WinRE integration getting stuck
Updates: Download overwrite previous Defender updates
Settings: Win10 News widget disabling
Download: NTLite 64-bit | 21.5 MB (Free, paid upgrade available)
Download: NTLite 32-bit | 19.3 MB
Link: NTLite Home Page | NTLite Features | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
Question
Pierce28
Hey,
I am currently working on a program to teach myself C#. In it, a person is "throwing" meatloaf at a picture of Hilary Clinton's head. (long story). I've created the picturebox containing Hilary's head from the toolbox, but I created my meatloaf pictureboxes from code. I have right clicked on Hilary's picture and selected "Send to Back", and used the Meatloaf.BringToFront();, but for some reason, the meatloaf always goes behind Hilary's head, making it hidden.
The code I used to set up the Meatloaf pictureboxes is
(global) public PictureBox[] picNewMeatLoaf = new PictureBox[20]; (In a FormLoad) for (int j = 1; j <= 19; j++) { picNewMeatLoaf[j] = new PictureBox(); picNewMeatLoaf[j].BringToFront(); } __________________________________ (In a AddMeatLoaf() procedure) this.SuspendLayout(); picNewMeatLoaf[i].Location = new Point(0, 0); picNewMeatLoaf[i].Size = new Size(75, 25); picNewMeatLoaf[i].BringToFront(); picNewMeatLoaf[i].Image = this.picMeatLoaf.Image; this.Controls.AddRange(new Control[] { picNewMeatLoaf[i] }); this.ResumeLayout(); ___________________________________ (in a timer) for (int j = 1; j < 20; j++) { if (this.picNewMeatLoaf[j].Top < 305 & picNewMeatLoaf[j].Left < 693) //305 is the ground level, 693 is the spot on Hilary's face to stop { this.picNewMeatLoaf[j].Top = picNewMeatLoaf[j].Top + 1; this.picNewMeatLoaf[j].Left = picNewMeatLoaf[j].Left + MeatLoafSpeed[j]; }
That is just the code related to the MeatLoaf picturebox, so obviously there is a lot more code. Note, this is my first real attempt at a program with C#, so the code isn't going to be the best.
Does anyone see what I'm doing wrong or have any suggestions? I'm all out of ideas, and I'd rather not have to just add it into the form1's background image. If you need anymore code or information, just let me know.
Oh, and if anyone has any ideas on how to make parts of picture boxes transparent, meaning they show the objects behind it, it would be VERY appreciated.
Pierce
Link to comment
https://www.neowin.net/forum/topic/559974-c-issue-with-making-one-picturebox-appear-ontop-of-another/Share on other sites
1 answer to this question
Recommended Posts