Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how can I get the original properties of my form back?

how can I get the original properties of my form back?

Scheduled Pinned Locked Moved C#
questiondesignhelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xkx32
    wrote on last edited by
    #1

    hi i have a win form... and i'm changing it's properties at runtime (e.g. BackColor) at some point i want to get back the orginal BackColor.. the color i specefied at design time. when i'm creating a new instance of the form and trying to copy the BackColor from it it's not working! it's as if i changed the class not an instance of it at runtime!!! please help me

    L C M 3 Replies Last reply
    0
    • X xkx32

      hi i have a win form... and i'm changing it's properties at runtime (e.g. BackColor) at some point i want to get back the orginal BackColor.. the color i specefied at design time. when i'm creating a new instance of the form and trying to copy the BackColor from it it's not working! it's as if i changed the class not an instance of it at runtime!!! please help me

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      If you create a new instance of the form that means you have a new form and you change the color of the new form. If you just want to change the backcolor, then use: this.BackColor = Color.Red; //(for example)

      1 Reply Last reply
      0
      • X xkx32

        hi i have a win form... and i'm changing it's properties at runtime (e.g. BackColor) at some point i want to get back the orginal BackColor.. the color i specefied at design time. when i'm creating a new instance of the form and trying to copy the BackColor from it it's not working! it's as if i changed the class not an instance of it at runtime!!! please help me

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        LOL - I just answered this on MSDN. Your form needs to call InitialiseComponent in order to have it's properties set. Create a method that sets the default properties, call it after InitialiseComponent and then call it again if you need to reset.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        1 Reply Last reply
        0
        • X xkx32

          hi i have a win form... and i'm changing it's properties at runtime (e.g. BackColor) at some point i want to get back the orginal BackColor.. the color i specefied at design time. when i'm creating a new instance of the form and trying to copy the BackColor from it it's not working! it's as if i changed the class not an instance of it at runtime!!! please help me

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          Hello, Before you change the Forms BackColor you have to save it at a global Color variable private Color oldBackColor; private void youreMethod() { //save your color oldBackColor = this.BackColor; this.BackColor = Color.???; } private void youreothermethod() { //get back youre color if(Iwhantit()==true) this.BackColor = oldBackColor; } Hope that helps you. All the best, Martin

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups