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. Visual Studio
  4. My Usercontrol behaves different in VS2010 and VS 2013

My Usercontrol behaves different in VS2010 and VS 2013

Scheduled Pinned Locked Moved Visual Studio
csharpgraphicsdotnetvisual-studiowinforms
3 Posts 2 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.
  • G Offline
    G Offline
    GrooverFromHolland
    wrote on last edited by
    #1

    Hi all, In my c# windows forms project I Have a user control. I have some code to create a blue border when clicked. If I debug my project in VS2013 all is working, but in VS 2010 express the color does not change! Both VS versions target the .NET framework 4. If I open my project directly in bin/Debug/ .exe it is not working. In bin/Release/ .exe it is working. This is the relevant code:

    private Control currentCsKeypadControl;

    public FormUserMain()
    {
    InitializeComponent();

            foreach (Control tb in tableLayoutPanelCsKeypad.Controls)
            {
                if (tb.GetType() == typeof(MyControl))
                {
                    MyControl control = tb as MyControl;
                    {
                        control.Click += delegate(object sender, EventArgs eventArgs)
                        {
                            tb.BackColor = Color.Blue;
                            timerKeyColor.Start();
                            currentCsKeypadControl = sender as MyControl;
                            currentCsKeypadControl.Invalidate();
                        };
                    }
                }
            }
    
         }
    

    private void timerKeyColor_Tick(object sender, EventArgs e)
    {

            timerKeyColor.Stop();
           if(!timerKeyColor.Enabled) currentCsKeypadControl.BackColor = Color.Transparent;
        }
    

    public class MyControl : Label
    {
    Image _image = null;

        public MyControl()
        {
            // Allow transparent background
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            // Default to transparent background
            this.BackColor = System.Drawing.Color.Transparent;
        }
    
        public Image Image
        {
            get
            {
                return \_image;
            }
            set
            {
                \_image = value;
            }
        } 
        protected override void OnPaint(PaintEventArgs e)
        {
            
            if (this.Image != null)
            {
                // Draw image smaller to create border with back color.
                e.Graphics.DrawImage(this.Image, 3, 3, this.Width - 6, this.Height - 6);
            }
            
            RectangleF rectangle = new RectangleF(2, 0, this.Width, this.Height + 5);
            StringFormat format = new StringFormat();
            format.LineAlignment = StringA
    
    Richard Andrew x64R 1 Reply Last reply
    0
    • G GrooverFromHolland

      Hi all, In my c# windows forms project I Have a user control. I have some code to create a blue border when clicked. If I debug my project in VS2013 all is working, but in VS 2010 express the color does not change! Both VS versions target the .NET framework 4. If I open my project directly in bin/Debug/ .exe it is not working. In bin/Release/ .exe it is working. This is the relevant code:

      private Control currentCsKeypadControl;

      public FormUserMain()
      {
      InitializeComponent();

              foreach (Control tb in tableLayoutPanelCsKeypad.Controls)
              {
                  if (tb.GetType() == typeof(MyControl))
                  {
                      MyControl control = tb as MyControl;
                      {
                          control.Click += delegate(object sender, EventArgs eventArgs)
                          {
                              tb.BackColor = Color.Blue;
                              timerKeyColor.Start();
                              currentCsKeypadControl = sender as MyControl;
                              currentCsKeypadControl.Invalidate();
                          };
                      }
                  }
              }
      
           }
      

      private void timerKeyColor_Tick(object sender, EventArgs e)
      {

              timerKeyColor.Stop();
             if(!timerKeyColor.Enabled) currentCsKeypadControl.BackColor = Color.Transparent;
          }
      

      public class MyControl : Label
      {
      Image _image = null;

          public MyControl()
          {
              // Allow transparent background
              SetStyle(ControlStyles.SupportsTransparentBackColor, true);
              // Default to transparent background
              this.BackColor = System.Drawing.Color.Transparent;
          }
      
          public Image Image
          {
              get
              {
                  return \_image;
              }
              set
              {
                  \_image = value;
              }
          } 
          protected override void OnPaint(PaintEventArgs e)
          {
              
              if (this.Image != null)
              {
                  // Draw image smaller to create border with back color.
                  e.Graphics.DrawImage(this.Image, 3, 3, this.Width - 6, this.Height - 6);
              }
              
              RectangleF rectangle = new RectangleF(2, 0, this.Width, this.Height + 5);
              StringFormat format = new StringFormat();
              format.LineAlignment = StringA
      
      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Have you tried "cleaning" the project and rebuilding it?

      The difficult we do right away... ...the impossible takes slightly longer.

      G 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        Have you tried "cleaning" the project and rebuilding it?

        The difficult we do right away... ...the impossible takes slightly longer.

        G Offline
        G Offline
        GrooverFromHolland
        wrote on last edited by
        #3

        Thank You Richard your suggestion worked. Thanks, Groover

        0200 A9 23 0202 8D 01 80 0205 00

        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