ComboBox(with Border) on C#,SPATIUM
 SPATIUM Desktop
주소복사
About Operating System Languages Tools Favorites Notice Visit TEST  
     ADK (2)
     android (3)
     ASP (5)
     ASP.Net (1)
     C# (5)
     HTML (9)
     JAVA (6)
     JavaScript (9)
     jQuery (5)
     Mobile Web (2)
     Oracle (8)
     PHP (7)
     Spring Framework (4)
     SQL (15)
     WPF (5)
   ID  
   Password  
  |  
  Location United States
  IP Address 54.81.196.35
2018. 08
1234
567891011
121314151617
18
19202122232425
262728293031
Category  Languages, C#
Writer 김태우 Date 2016-04-05 16:54:40 Visit 1452
ComboBox(with Border) on C#
 
 
    public partial class ExCombobox : ComboBox
    {
        private const int WM_PAINT = 0xF;
        private const int WM_NC_PAINT = 0x85;
        private IntPtr hDC;
        private Graphics gdc;
        private Rectangle rectBorder;
 
        private Color borderColor = Color.Black;
        private ButtonBorderStyle borderStyle;
 
        
 
        [DllImport("user32")]
        private static extern IntPtr GetWindowDC(IntPtr hWnd);
 
        [DllImport("user32")]
        private static extern IntPtr GetDC(IntPtr hWnd);
 
        [DllImport("user32")]
        private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
 
        [Category("Appearance")]
        public Color BorderColor
        {
            get { return this.borderColor; }
            set { this.borderColor = value; }
        }
 
        [Category("Appearance")]
        public ButtonBorderStyle BorderStyle
        {
            get { return this.borderStyle; }
            set { this.borderStyle = value; }
        }
 
        public ExCombobox()
        {
            this.hDC = GetDC(Handle);
            this.gdc = Graphics.FromHdc(hDC);
            this.rectBorder = new Rectangle(0, 0, this.Width, this.Height);
 
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
        }
 
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_NC_PAINT:
                    break;
                case WM_PAINT:
                    base.WndProc(ref m);
                    ControlPaint.DrawBorder(gdc, this.rectBorder, this.borderColor, this.borderStyle);
                    break;
                default:
                    base.WndProc(ref m);
                    break;
            }
        }
 
        protected override void OnResize(EventArgs e)
        {
            this.hDC = GetDC(Handle);
            this.gdc = Graphics.FromHdc(hDC);
            this.rectBorder = new Rectangle(0, 0, this.Width, this.Height);
            Invalidate();
            base.OnResize(e);
        }
 
        public void setDataSource(Object bindingSource, String keyName, String valueName){
            this.DataSource = bindingSource;
            this.DisplayMember = keyName;
            this.ValueMember = valueName;
        }
    }
 
 
Tags  ComboBox, c#, Border
  Relation Articles
[Languages-C#] TextBox(with Border) on C# (2016-04-05 17:00:59)
[Languages-C#] ComboBox(with Border) on C# (2016-04-05 16:54:40)
[Languages-C#] Flicker해결(DoubleBuffer) on C# (2016-01-28 17:24:13)
  Your Opinion
Member ID
150 letters
Copyright (C) SPATIUM. All rights reserved.
[SPATIUM]WebMaster Mail