Click here to Skip to main content
15,905,616 members
Home / Discussions / C#
   

C#

 
GeneralRe: Coding music rhythms Pin
PIEBALDconsult25-Sep-14 6:22
mvePIEBALDconsult25-Sep-14 6:22 
GeneralRe: Coding music rhythms Pin
Navid Abyazi25-Sep-14 7:15
professionalNavid Abyazi25-Sep-14 7:15 
GeneralRe: Coding music rhythms Pin
PIEBALDconsult26-Sep-14 8:08
mvePIEBALDconsult26-Sep-14 8:08 
AnswerRe: Coding music rhythms Pin
Pete O'Hanlon24-Sep-14 8:40
mvePete O'Hanlon24-Sep-14 8:40 
GeneralRe: Coding music rhythms Pin
PIEBALDconsult24-Sep-14 8:44
mvePIEBALDconsult24-Sep-14 8:44 
GeneralRe: Coding music rhythms Pin
Bernhard Hiller24-Sep-14 20:49
Bernhard Hiller24-Sep-14 20:49 
GeneralRe: Coding music rhythms Pin
Pete O'Hanlon24-Sep-14 20:58
mvePete O'Hanlon24-Sep-14 20:58 
GeneralRe: Coding music rhythms Pin
PIEBALDconsult25-Sep-14 6:23
mvePIEBALDconsult25-Sep-14 6:23 
GeneralRe: Coding music rhythms Pin
Navid Abyazi25-Sep-14 7:19
professionalNavid Abyazi25-Sep-14 7:19 
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 

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.