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. General problem with c sharp in VS2005

General problem with c sharp in VS2005

Scheduled Pinned Locked Moved C#
helpcsharpc++visual-studiotools
6 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.
  • J Offline
    J Offline
    jgrogan
    wrote on last edited by
    #1

    I'm very new to C sharp, having come from a c++ and vb background. Within VS2005, I have a script (MainForm.Designer.cs) that defines all the components in my project (mostly toolstripmenus, buttons, labels, comboboxes etc.), the events attached to them etc However, every time I try to group the code into logical blocks (including using regions) and save it, when I re-open VS mixes it all up again. I've gone through the help and even tried MSDN, but haven't found a way around this. Anyone got any ideas? Thanks in Advance, John.

    L 1 Reply Last reply
    0
    • J jgrogan

      I'm very new to C sharp, having come from a c++ and vb background. Within VS2005, I have a script (MainForm.Designer.cs) that defines all the components in my project (mostly toolstripmenus, buttons, labels, comboboxes etc.), the events attached to them etc However, every time I try to group the code into logical blocks (including using regions) and save it, when I re-open VS mixes it all up again. I've gone through the help and even tried MSDN, but haven't found a way around this. Anyone got any ideas? Thanks in Advance, John.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, all .Designer.cs files are generated automatically by Visual Designer; you are not supposed to modify them in any way other than through the Designer. So you should put your own code in one or more separate files. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Happy Holidays!


      J 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, all .Designer.cs files are generated automatically by Visual Designer; you are not supposed to modify them in any way other than through the Designer. So you should put your own code in one or more separate files. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Happy Holidays!


        J Offline
        J Offline
        jgrogan
        wrote on last edited by
        #3

        Thanks Luc, Just so I understand correctly, are you suggesting that I put the code from the designer script into my own script and simply call the functions from the designer script? Best, John.

        L D P 3 Replies Last reply
        0
        • J jgrogan

          Thanks Luc, Just so I understand correctly, are you suggesting that I put the code from the designer script into my own script and simply call the functions from the designer script? Best, John.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          why would you do any of that? Leave the Designer code as is, where it is; the .Designer.cs files are part of your project, they will be included in all your builds. And there is nothing to call except for InitializeComponent(), which should be called as the first statement in your form's constructor (the wizzard will have put it there for you too). :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Happy Holidays!


          1 Reply Last reply
          0
          • J jgrogan

            Thanks Luc, Just so I understand correctly, are you suggesting that I put the code from the designer script into my own script and simply call the functions from the designer script? Best, John.

            D Offline
            D Offline
            DaveyM69
            wrote on last edited by
            #5

            You'll notice that your MainForm.cs and MainForm.Designer.cs both have: public partial class MainForm within the same namespace. The designer file is handled by the IDE and automatically updated everytime design changes are made (this can include project opening etc). You shouldn't normally make any changes to the designer file yourself. Your own 'functions' and calls to them should be added in the MainForm.cs file, or alternatively create your own MainForm.Functions.cs and/or MainForm.FunctionCalls.cs file and start these files with the namespace required and the public partial class MainForm { .... }

            1 Reply Last reply
            0
            • J jgrogan

              Thanks Luc, Just so I understand correctly, are you suggesting that I put the code from the designer script into my own script and simply call the functions from the designer script? Best, John.

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #6

              jgrogan wrote:

              are you suggesting that I put the code from the designer script into my own script and simply call the functions from the designer script?

              No, leave them as they are.

              "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

              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