Click here to Skip to main content
15,881,248 members
Articles / Desktop Programming / Windows Forms

ExControls Version 1.0

Rate me:
Please Sign up or sign in to vote.
4.69/5 (32 votes)
27 Oct 20066 min read 107.4K   4.2K   113  
Extending some C# controls to introudce round labels, text boxes, comboboxes etc.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Design;

namespace ExControls
{
    [LookupBindingProperties("DataSource", "DataMember", "ValueMember", "LookupMember")]
    public partial class ComboBoxEntry : BaseEntry
    {
        public ComboBoxEntry()
        {
            InitializeComponent();

            maximumHeight = 32;

            SetHostedControl(entryComboBox);
        }

        #region Entry ComoboBox Properties
        [DisplayName("ComboBox")]
        [Category("ComboBoxEntry")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Description("ComboBox Control")]
        public ComboBox ComboBoxControl
        {
            get { return entryComboBox; }
        }
        [Category("ComboBoxEntry")]
        [AttributeProvider(typeof(IListSource))]
        public object DataSource
        {
            get { return entryComboBox.DataSource; }
            
            set { entryComboBox.DataSource = value; }
        }

        [Category("ComboBoxEntry")]
        [TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
        [Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
        public string DataMember
        {
            get { return entryComboBox.DisplayMember; }
            
            set { entryComboBox.DisplayMember = value; }
        }
        
        [Category("ComboBoxEntry")]
        [Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
        public string ValueMember
        {
            get { return entryComboBox.ValueMember; }
            
            set { entryComboBox.ValueMember = value; }
        }
        [Category("ComboBoxEntry")]
        [DesignerSerializationVisibility(0)]
        [Browsable(false)]
        [Bindable(true)]
        [DefaultValue("")]
         public string LookupMember
        {
            get 
            {
                if (entryComboBox.SelectedValue != null)
                {
                    return entryComboBox.SelectedValue.ToString();
                }
                else
                {
                    return "";
                }
            }
            
            set { entryComboBox.SelectedValue = value; }
        }
        #endregion

        #region events

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect Nebras Technology
Egypt Egypt
With a heavy C++/MFC background started my way to the DotNet and C# world.
Going from device drivers to standard windows applications development using C++/MFC since 1998, I started the switch to .Net technology in 2004.
Currently I am the Technical Development Manager and Software Architect of Nebras Technology (Medical Software Vendor) and one of its executives owners.

Comments and Discussions