How To Set Background Image In Windows Form In C#
#i
C# Windows Form Application Groundwork Image: How to Salve
Posted 01 March 2022 - 08:55 PM
Hi, I need help with a C# Windows form application. My application is mostly done and all the settings save through save.settings. But the brusque of it is the app will load and have a default groundwork image. The user can select from a listing of embedded images and change the background. The update works fine. The trouble is when the user closes the app and re-opens information technology the default image loads and not the new image. So how do I save the background prototype with salve.settings or another method?
#2
Re: C# Windows Grade Application Background Epitome: How to Save
Posted 01 March 2022 - 09:52 PM
Show us your code for how you are saving and loading the groundwork settings.
#3
Re: C# Windows Form Application Groundwork Paradigm: How to Save
Posted 01 March 2022 - x:08 PM
See code below.
//Loads data from relieve settings on form load individual void lbl_Prestige_Load(object sender, EventArgs e) { lbl_MWlevel.Text = Properties.Settings.Default.MWlevel; lbl_MWPrestige.Text = Properties.Settings.Default.MWPrestige; lbl_MWKD.Text = Properties.Settings.Default.MWKD; lbl_MW2KD.Text = Properties.Settings.Default.MW2KD; lbl_MW2lvl.Text = Properties.Settings.Default.MW2lvl; lbl_MW2Prestige.Text = Backdrop.Settings.Default.MW2Prestige; lbl_MW3KD.Text = Backdrop.Settings.Default.MW3KD; lbl_MW3lvl.Text = Properties.Settings.Default.MW3lvl; lbl_MW3Prestige.Text = Backdrop.Settings.Default.MW3Prestige; lbl_BOKD.Text = Properties.Settings.Default.BOKD; lbl_BOlvl.Text = Properties.Settings.Default.BOlvl; lbl_BOPrestige.Text = Properties.Settings.Default.BOPrestige; lbl_BO2KD.Text = Properties.Settings.Default.BO2KD; lbl_BO2lvl.Text = Properties.Settings.Default.BO2lvl; lbl_BO2Prestige.Text = Properties.Settings.Default.BO2Prestige; lbl_BO3KD.Text = Properties.Settings.Default.BO3KD; lbl_BO3lvl.Text = Backdrop.Settings.Default.BO3lvl; lbl_BO3Prestige.Text = Properties.Settings.Default.BO3Prestige; lbl_AWKD.Text = Backdrop.Settings.Default.AWKD; lbl_AWlvl.Text = Backdrop.Settings.Default.AWlvl; lbl_AWPrestige.Text = Backdrop.Settings.Default.AWPrestige; lbl_GhostsKD.Text = Properties.Settings.Default.GhostsKD; lbl_Ghostslvl.Text = Properties.Settings.Default.Ghostslvl; lbl_GhostsPre.Text = Properties.Settings.Default.GhostsPrestige; lbl_WAWKD.Text = Backdrop.Settings.Default.WAWKD; lbl_WAWlvl.Text = Properties.Settings.Default.WAWlvl; lbl_WAWPrestige.Text = Properties.Settings.Default.WAWPrestige; lbl_GamerTag.Text = Properties.Settings.Default.Gamertag; // Saves data on class close private void lbl_Prestige_FormClosed(object sender, FormClosedEventArgs e) { Backdrop.Settings.Default.MWlevel = lbl_MWlevel.Text; Properties.Settings.Default.MWKD = lbl_MWKD.Text; Properties.Settings.Default.MWPrestige = lbl_MWPrestige.Text; Backdrop.Settings.Default.MW2KD = lbl_MW2KD.Text; Properties.Settings.Default.MW2lvl = lbl_MW2lvl.Text; Properties.Settings.Default.MW2Prestige = lbl_MW2Prestige.Text; Backdrop.Settings.Default.MW3KD = lbl_MW3KD.Text; Properties.Settings.Default.MW3lvl = lbl_MW3lvl.Text; Backdrop.Settings.Default.MW3Prestige = lbl_MW3Prestige.Text; Backdrop.Settings.Default.BOKD = lbl_BOKD.Text; Properties.Settings.Default.BOlvl = lbl_BOlvl.Text; Backdrop.Settings.Default.BOPrestige = lbl_BOPrestige.Text; Properties.Settings.Default.BO2KD = lbl_BO2KD.Text; Backdrop.Settings.Default.BO2lvl = lbl_BO2lvl.Text; Properties.Settings.Default.BO2Prestige = lbl_BO2Prestige.Text; Properties.Settings.Default.BO3KD = lbl_BO3KD.Text; Properties.Settings.Default.BO3lvl = lbl_BO3lvl.Text; Properties.Settings.Default.BO3Prestige = lbl_BO3Prestige.Text; Properties.Settings.Default.AWKD = lbl_AWKD.Text; Properties.Settings.Default.AWlvl = lbl_AWlvl.Text; Properties.Settings.Default.AWPrestige = lbl_AWPrestige.Text; Backdrop.Settings.Default.GhostsKD = lbl_GhostsKD.Text; Properties.Settings.Default.Ghostslvl = lbl_Ghostslvl.Text; Properties.Settings.Default.GhostsPrestige = lbl_GhostsPre.Text; Properties.Settings.Default.WAWKD = lbl_WAWKD.Text; Properties.Settings.Default.WAWlvl = lbl_WAWlvl.Text; Backdrop.Settings.Default.WAWPrestige = lbl_WAWPrestige.Text; Backdrop.Settings.Default.Gamertag = lbl_GamerTag.Text; Properties.Settings.Default.Save(); } Actually the code I simply listed is for all the settings on the form except the back footing. I do not know how to save the groundwork prototype considering in salvage settings I am non certain what type to apply. As for loading the background settings I simply just put an epitome in the resources and and then made a default image in the background prototype department in properties under appearance. Then I accept this lawmaking below that will switch the prototype when the user selects it from a combo box.
private void button1_Click(object sender, EventArgs east) { switch (comboBox1.SelectedIndex) { case 0: form1.BackgroundImage = Properties.Resources.call_of_duty_modern_warfare_2; break; case 1: form1.BackgroundImage = Properties.Resources.zombies_new; break; example 2: form1.BackgroundImage = Properties.Resources.Onslaught_Michael_Myers; break; case three: form1.BackgroundImage = Backdrop.Resources.ghost_modern_warfare_two_x_call_of_duty_253888_1024x575; intermission; case 4: form1.BackgroundImage = base of operations.BackgroundImage; pause; } this.Shut(); This mail has been edited past Skydiver: 01 March 2022 - 10:15 PM
Reason for edit:: Put code in code tags, learn to practice this yourself.
#4
Re: C# Windows Grade Awarding Background Prototype: How to Save
Posted 01 March 2022 - x:xiv PM
Move your background setting lawmaking out of your button click handler and into a method that takes an integer. In your push button click handler, call the method passing in the selected combobox alphabetize. Also save the selected combobox index into your settings. In your form load handler, call the method passing in the alphabetize that yous saved in your settings.
#v
Re: C# Windows Grade Application Groundwork Epitome: How to Relieve
Posted 01 March 2022 - 10:21 PM
Thanks for the reply but not sure that I follow. I'm non an expert at C# and still learning. Could you please provide an example?
Also, how practice I save the selected combobox index into my settings?
#6
Re: C# Windows Course Application Background Image: How to Save
Posted 02 March 2022 - 06:45 AM
So instead of:
void DetonateButton_Click(object sender, EventArgs e) { int time = 0; if (int.TryParse(TimeLimitTextBox.Text, out time)) CountDownTimer.TimeLimit = time; } Yous would have:
void SetTimer(cord text) { int time = 0; if (int.TryParse(text, out time)) CountDownTimer.TimeLimit = time; } void DetonateButton_Click(object sender, EventArgs e) { SetTimer(TimeLimitTextBox.Value); } And yous are kidding nigh needing an instance about saving and loading to settings, right? You already have code that loads and saves settings. It's exactly the same principle.
How To Set Background Image In Windows Form In C#,
Source: https://www.dreamincode.net/forums/topic/389727-c%23-windows-form-application-background-image-how-to-save/
Posted by: harringtonyaripped.blogspot.com

0 Response to "How To Set Background Image In Windows Form In C#"
Post a Comment