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. ControlDesigner issue

ControlDesigner issue

Scheduled Pinned Locked Moved C#
helpquestioncsharpdesigntutorial
5 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.
  • M Offline
    M Offline
    mo1492
    wrote on last edited by
    #1

    Not sure if this is the correct group for this question but I am working with C#. I'm migrating from VS2005 to VS2022 and having problem with ControlDesigner in my Control. It seems that the ControlDesigner is not functioning. I'm not too familiar with ControlDesigner programming so after working on this for a while I decided to start from scratch. I found an example in Microsoft Help Viewer for ControlDesigner. I copied and pasted the example code into a project UserControl1 and it too does not seem to function. When moving the mouse over the control the outline does not highlight and also the OutlineColor property is not shown in the Properties window. Can someone help? Below is the sample code from Help Viewer. The only difference the test control is called UserControl1 Thank you.

    using System.ComponentModel;

    namespace TestApp
    {
    // ExampleControlDesigner is an example control designer that
    // demonstrates basic functions of a ControlDesigner.
    public class ExampleControlDesigner : System.Windows.Forms.Design.ControlDesigner
    {
    // This Boolean state reflects whether the mouse is over the control.
    private bool mouseover = false;
    // This color is a private field for the OutlineColor property.
    private Color lineColor = Color.White;

        // This color is used to outline the control when the mouse is 
        // over the control.
        public Color OutlineColor
        {
            get
            {
                return lineColor;
            }
            set
            {
                lineColor = value;
            }
        }
    
        public ExampleControlDesigner()
        {
        }
    
        // Sets a value and refreshes the control's display when the 
        // mouse position enters the area of the control.
        protected override void OnMouseEnter()
        {
            this.mouseover = true;
            this.Control.Refresh();
        }
    
        // Sets a value and refreshes the control's display when the 
        // mouse position enters the area of the control.        
        protected override void OnMouseLeave()
        {
            this.mouseover = false;
            this.Control.Refresh();
        }
    
        // Draws an outline around the control when the mouse is 
        // over the control.    
        protected override void OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe)
        {
            if (this.mouseover)
            {
                pe.Grap
    
    L 1 Reply Last reply
    0
    • M mo1492

      Not sure if this is the correct group for this question but I am working with C#. I'm migrating from VS2005 to VS2022 and having problem with ControlDesigner in my Control. It seems that the ControlDesigner is not functioning. I'm not too familiar with ControlDesigner programming so after working on this for a while I decided to start from scratch. I found an example in Microsoft Help Viewer for ControlDesigner. I copied and pasted the example code into a project UserControl1 and it too does not seem to function. When moving the mouse over the control the outline does not highlight and also the OutlineColor property is not shown in the Properties window. Can someone help? Below is the sample code from Help Viewer. The only difference the test control is called UserControl1 Thank you.

      using System.ComponentModel;

      namespace TestApp
      {
      // ExampleControlDesigner is an example control designer that
      // demonstrates basic functions of a ControlDesigner.
      public class ExampleControlDesigner : System.Windows.Forms.Design.ControlDesigner
      {
      // This Boolean state reflects whether the mouse is over the control.
      private bool mouseover = false;
      // This color is a private field for the OutlineColor property.
      private Color lineColor = Color.White;

          // This color is used to outline the control when the mouse is 
          // over the control.
          public Color OutlineColor
          {
              get
              {
                  return lineColor;
              }
              set
              {
                  lineColor = value;
              }
          }
      
          public ExampleControlDesigner()
          {
          }
      
          // Sets a value and refreshes the control's display when the 
          // mouse position enters the area of the control.
          protected override void OnMouseEnter()
          {
              this.mouseover = true;
              this.Control.Refresh();
          }
      
          // Sets a value and refreshes the control's display when the 
          // mouse position enters the area of the control.        
          protected override void OnMouseLeave()
          {
              this.mouseover = false;
              this.Control.Refresh();
          }
      
          // Draws an outline around the control when the mouse is 
          // over the control.    
          protected override void OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe)
          {
              if (this.mouseover)
              {
                  pe.Grap
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Here's the same code; only more complete, it seems. [ControlDesigner Class (System.Windows.Forms.Design) | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.design.controldesigner?view=windowsdesktop-6.0)

      "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

      M 1 Reply Last reply
      0
      • L Lost User

        Here's the same code; only more complete, it seems. [ControlDesigner Class (System.Windows.Forms.Design) | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.design.controldesigner?view=windowsdesktop-6.0)

        "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

        M Offline
        M Offline
        mo1492
        wrote on last edited by
        #3

        Yes this is the example where a copied the test code from. I tried this example 'as is' but it did not work. The code in my question is the same; It just uses a UserControl1 that I created in my test project while debugging. I did not include the UserControl1.Designer.cs code which includes the other code. Thank you

        L 1 Reply Last reply
        0
        • M mo1492

          Yes this is the example where a copied the test code from. I tried this example 'as is' but it did not work. The code in my question is the same; It just uses a UserControl1 that I created in my test project while debugging. I did not include the UserControl1.Designer.cs code which includes the other code. Thank you

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

          It's not the same; it does not have / or you removed the disposing code. Or did you think it just wasn't important so it's: "as is"?

          "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

          M 1 Reply Last reply
          0
          • L Lost User

            It's not the same; it does not have / or you removed the disposing code. Or did you think it just wasn't important so it's: "as is"?

            "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

            M Offline
            M Offline
            mo1492
            wrote on last edited by
            #5

            I'm sorry for the confusion. There are 2 files to a UserControl when created from the application: In this case UserControl1.cs UserControl1.Designer.cs The latter file contains the standard Dispose() code which I did not supply since it's just standard code. For arguments sake, I started with the code you referenced 'as is'.. That means I copied and pasted the whole sample into a project file, built it, and tried it by loading it into a from from the toolbox; it did not function as described... 1. When the mouse moves into the control, the control does not show the highlight the border as the MouseEnter() method should do. 2. The property that is added in the designer "OutlineColor" does not show in the grid properties. I've managed to get the debugger to work in DesignMode and set a break points in the MouseEnter() method and the OutLineColor.Set property and the OnPaintAdornments() method. None of the break points are hit when the control is loaded into the form. thanks

            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