Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
GeneralRe: Coding music rhythms Pin
PIEBALDconsult26-Sep-14 2:55
mvePIEBALDconsult26-Sep-14 2:55 
GeneralRe: Coding music rhythms Pin
PIEBALDconsult30-Sep-14 10:52
mvePIEBALDconsult30-Sep-14 10:52 
AnswerRe: Coding music rhythms Pin
Bassam Abdul-Baki3-Oct-14 5:57
professionalBassam Abdul-Baki3-Oct-14 5:57 
AnswerRe: Coding music rhythms Pin
Bassam Abdul-Baki3-Oct-14 7:19
professionalBassam Abdul-Baki3-Oct-14 7:19 
AnswerRe: Coding music rhythms Pin
Bassam Abdul-Baki5-Oct-14 11:42
professionalBassam Abdul-Baki5-Oct-14 11:42 
QuestionHow to prevent a child control to be added in usercontrol Pin
Phil Thomson24-Sep-14 4:43
Phil Thomson24-Sep-14 4:43 
AnswerRe: How to prevent a child control to be added in usercontrol Pin
BillWoodruff24-Sep-14 6:11
professionalBillWoodruff24-Sep-14 6:11 
GeneralRe: How to prevent a child control to be added in usercontrol Pin
Phil Thomson24-Sep-14 6:49
Phil Thomson24-Sep-14 6:49 
Hi BillWoodruff,

Let's say I want to do this in a design-time scenario.

I add my usercontrol to the form and I want to prevent other programmer to add control in it.


C#
[Designer(typeof(MyControlDesigner))]
public partial class GroupInput : UserControl
{

  private Color _BorderColor = Color.Black;
  [Category("Appearance")]
  [Description("Set the border color")]
  [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
  [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
  public Color BorderColor
    {
        get { return _BorderColor; }
        set {
            _BorderColor = value;this.Refresh();
        }

  }

  public GroupInput()
    {
        SetStyle(ControlStyles.ResizeRedraw, true);
        SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        SetStyle(ControlStyles.DoubleBuffer, true);
        SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

    }

      protected override void OnPaint(PaintEventArgs e)
      {
          base.OnPaint(e);
          ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, this._BorderColor, ButtonBorderStyle.Solid);


      }



}

 internal class MyControlDesigner : ParentControlDesigner
    {

        // This defines the size of the anchor glyphs. 
        private const int glyphSize = 6;

        // This defines the size of the hit bounds for an AnchorGlyph. 
        private const int hitBoundSize = glyphSize + 4;


        // This demonstrates changing the appearance of a control while 
        // it is being designed. In this case, the BackColor property is 
        // set to LightBlue.  
        private GroupInput _groupInput = null;
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);
            _groupInput = (GroupInput)component;
        }

        public override void InitializeNewComponent(IDictionary defaultValues)
        {
            base.InitializeNewComponent(defaultValues);

            PropertyDescriptor colorPropDesc =
                TypeDescriptor.GetProperties(Component)["BorderColor"];

            if (colorPropDesc != null &&
                colorPropDesc.PropertyType == typeof(Color) &&
                !colorPropDesc.IsReadOnly &&
                colorPropDesc.IsBrowsable)
            {
                colorPropDesc.SetValue(Component, Color.LightBlue);
            }
        }

        protected override void OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe)
        {
            _groupInput = (GroupInput)Component;
            base.OnPaintAdornments(pe);
            ControlPaint.DrawBorder(pe.Graphics, _groupInput.ClientRectangle, _groupInput.BorderColor, ButtonBorderStyle.Solid);

        }
}

AnswerRe: How to prevent a child control to be added in usercontrol Pin
BillWoodruff24-Sep-14 21:41
professionalBillWoodruff24-Sep-14 21:41 
GeneralRe: How to prevent a child control to be added in usercontrol Pin
Phil Thomson25-Sep-14 10:01
Phil Thomson25-Sep-14 10:01 
GeneralRe: How to prevent a child control to be added in usercontrol Pin
BillWoodruff25-Sep-14 20:46
professionalBillWoodruff25-Sep-14 20:46 
QuestionHow to stop exposing multiple endpoint at client side in WCF Pin
Tridip Bhattacharjee24-Sep-14 4:23
professionalTridip Bhattacharjee24-Sep-14 4:23 
SuggestionRe: How to stop exposing multiple endpoint at client side in WCF Pin
Richard MacCutchan24-Sep-14 5:33
mveRichard MacCutchan24-Sep-14 5:33 
AnswerRe: How to stop exposing multiple endpoint at client side in WCF Pin
Dominic Burford24-Sep-14 5:43
professionalDominic Burford24-Sep-14 5:43 
GeneralRe: How to stop exposing multiple endpoint at client side in WCF Pin
Tridip Bhattacharjee24-Sep-14 21:35
professionalTridip Bhattacharjee24-Sep-14 21:35 
GeneralRe: How to stop exposing multiple endpoint at client side in WCF Pin
Dominic Burford25-Sep-14 1:24
professionalDominic Burford25-Sep-14 1:24 
GeneralRe: How to stop exposing multiple endpoint at client side in WCF Pin
Tridip Bhattacharjee25-Sep-14 2:39
professionalTridip Bhattacharjee25-Sep-14 2:39 
GeneralRe: How to stop exposing multiple endpoint at client side in WCF Pin
Dominic Burford25-Sep-14 3:57
professionalDominic Burford25-Sep-14 3:57 
Questionerror: "Not a legal OleAut"when importing Excel2007 into SQL Pin
Member 245846723-Sep-14 21:51
Member 245846723-Sep-14 21:51 
AnswerRe: error: "Not a legal OleAut"when importing Excel2007 into SQL Pin
Bernhard Hiller24-Sep-14 20:56
Bernhard Hiller24-Sep-14 20:56 
QuestionRegarding a basic question about Serialization Pin
Tridip Bhattacharjee23-Sep-14 21:26
professionalTridip Bhattacharjee23-Sep-14 21:26 
AnswerRe: Regarding a basic question about Serialization PinPopular
Eddy Vluggen23-Sep-14 21:50
professionalEddy Vluggen23-Sep-14 21:50 
AnswerRe: Regarding a basic question about Serialization Pin
George Jonsson24-Sep-14 18:14
professionalGeorge Jonsson24-Sep-14 18:14 
AnswerRe: Regarding a basic question about Serialization Pin
Sibeesh KV24-Sep-14 18:43
professionalSibeesh KV24-Sep-14 18:43 
Questionusing Peachtree API in C# Pin
Jassim Rahma23-Sep-14 11:08
Jassim Rahma23-Sep-14 11:08 

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.