Пример #1
0
        /// <summary>
        /// This member overrides the <see cref="System.Windows.Forms.Control.OnPaint"/> method.
        /// </summary>
        /// <param name="pe">A <see cref="System.Windows.Forms.PaintEventArgs"/> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs pe)
        {
            // Calling the base class OnPaint
            base.OnPaint(pe);

            // clear everything
            pe.Graphics.Clear(BackColor);

            // draw the combobox behind, if visual styles are enabled and available
            if ((ComboBoxRenderer.IsSupported) & (Application.RenderWithVisualStyles))
            {
                ComboBoxRenderer.DrawTextBox(pe.Graphics, this.ClientRectangle, ComboBoxState.Normal);
            }

            // draw the icon
            if (displayIcon)
            {
                DrawIconEventArgs e = new DrawIconEventArgs(pe.Graphics, iconRect);
                EventHandler <DrawIconEventArgs> handler = this.DrawIcon;
                if (handler != null)
                {
                    handler(this, e);
                }
            }

            // draw the text
            this.DrawTextArea(pe.Graphics);

            // draw the button
            DrawButton(pe.Graphics, ComboBoxState.Normal);

            // draw the border using normal ControlPaint, if visual styles are not available.
            if (!(ComboBoxRenderer.IsSupported) | !(Application.RenderWithVisualStyles))
            {
                ControlPaint.DrawBorder3D(pe.Graphics, 0, 0, Width, Height, Border3DStyle.Sunken);
            }
        }
Пример #2
0
 private void displayControl_DrawIcon(object sender, DrawIconEventArgs e)
 {
     this.RaiseDrawIconEvent(e);
 }