Click here to Skip to main content
15,895,011 members
Home / Discussions / C#
   

C#

 
GeneralRe: Mocking HttpContext Pin
SreeRama Govind3-Aug-22 8:59
SreeRama Govind3-Aug-22 8:59 
QuestionControlDesigner issue Pin
mo149230-Jul-22 0:51
mo149230-Jul-22 0:51 
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.

C#
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.Graphics.DrawRectangle(
                    new Pen(new SolidBrush(this.lineColor), 6),
                    0,
                    0,
                    this.Control.Size.Width,
                    this.Control.Size.Height);
            }
        }

        // Adds a property to this designer's control at design time 
        // that indicates the outline color to use. 
        // The DesignOnlyAttribute ensures that the OutlineColor
        // property is not serialized by the designer.
        protected override void PreFilterProperties(System.Collections.IDictionary properties)
        {
            PropertyDescriptor pd = TypeDescriptor.CreateProperty(
                typeof(ExampleControlDesigner),
                "OutlineColor",
                typeof(System.Drawing.Color),
                new Attribute[] { new DesignOnlyAttribute(true) });

            properties.Add("OutlineColor", pd);
        }
    }

    // This example control demonstrates the ExampleControlDesigner.
    [DesignerAttribute(typeof(ExampleControlDesigner))]
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }
    }
}

Frown | :(

modified 30-Jul-22 7:42am.

AnswerRe: ControlDesigner issue Pin
Gerry Schmitz30-Jul-22 5:04
mveGerry Schmitz30-Jul-22 5:04 
GeneralRe: ControlDesigner issue Pin
mo149230-Jul-22 7:35
mo149230-Jul-22 7:35 
GeneralRe: ControlDesigner issue Pin
Gerry Schmitz30-Jul-22 14:49
mveGerry Schmitz30-Jul-22 14:49 
GeneralRe: ControlDesigner issue Pin
mo149231-Jul-22 6:43
mo149231-Jul-22 6:43 
Questionhow to save Image or Bitmap to svg file Pin
Le@rner29-Jul-22 1:51
Le@rner29-Jul-22 1:51 
AnswerRe: how to save Image or Bitmap to svg file Pin
OriginalGriff29-Jul-22 2:19
mveOriginalGriff29-Jul-22 2:19 
AnswerRe: how to save Image or Bitmap to svg file Pin
Gerry Schmitz29-Jul-22 8:38
mveGerry Schmitz29-Jul-22 8:38 
AnswerRe: how to save Image or Bitmap to svg file Pin
Calin Negru30-Jul-22 2:42
Calin Negru30-Jul-22 2:42 
QuestionCan you use sqlite in vs2022? CLOSED Pin
mo149228-Jul-22 13:18
mo149228-Jul-22 13:18 
AnswerRe: Can you use sqlite in vs2022? CLOSED Pin
OriginalGriff28-Jul-22 19:00
mveOriginalGriff28-Jul-22 19:00 
QuestionC# Set voice in Text to Speech Pin
Rockallica27-Jul-22 17:02
Rockallica27-Jul-22 17:02 
AnswerRe: C# Set voice in Text to Speech Pin
OriginalGriff27-Jul-22 20:16
mveOriginalGriff27-Jul-22 20:16 
GeneralRe: C# Set voice in Text to Speech Pin
Rockallica28-Jul-22 8:39
Rockallica28-Jul-22 8:39 
GeneralRe: C# Set voice in Text to Speech Pin
OriginalGriff28-Jul-22 8:52
mveOriginalGriff28-Jul-22 8:52 
QuestionIn C# can't introduce a formula in Excel Pin
Ismael_199927-Jul-22 12:37
Ismael_199927-Jul-22 12:37 
AnswerRe: In C# can't introduce a formula in Excel Pin
trønderen27-Jul-22 12:55
trønderen27-Jul-22 12:55 
AnswerRe: In C# can't introduce a formula in Excel Pin
Gerry Schmitz27-Jul-22 14:47
mveGerry Schmitz27-Jul-22 14:47 
GeneralRe: In C# can't introduce a formula in Excel Pin
Ismael_199928-Jul-22 7:53
Ismael_199928-Jul-22 7:53 
QuestionI having this error could anyone can help me :Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at ValidParenthese.Solution.IsValid (System.String s) [0x00000] in <89120c6f256647e6a05011f274f6a Pin
swethamaddi26-Jul-22 23:20
swethamaddi26-Jul-22 23:20 
AnswerRe: I having this error could anyone can help me :Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at ValidParenthese.Solution.IsValid (System.String s) [0x00000] in <89120c6f256647e6a05011f27 Pin
Richard MacCutchan26-Jul-22 23:51
mveRichard MacCutchan26-Jul-22 23:51 
AnswerRe: I having this error could anyone can help me :Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at ValidParenthese.Solution.IsValid (System.String s) [0x00000] in <89120c6f256647e6a05011f27 Pin
Dave Kreskowiak27-Jul-22 6:57
mveDave Kreskowiak27-Jul-22 6:57 
QuestionWhat Is NullReferenceException? Object reference not set to an instance of an object i have error how to change code unable to excute below code could help me Pin
swethamaddi26-Jul-22 23:15
swethamaddi26-Jul-22 23:15 
AnswerRe: What Is NullReferenceException? Object reference not set to an instance of an object i have error how to change code unable to excute below code could help me Pin
Richard MacCutchan26-Jul-22 23:51
mveRichard MacCutchan26-Jul-22 23:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.