Thanks viki:
here is my code:
-
using System;
-
using System.Collections.Generic;
-
using System.ComponentModel;
-
using System.Drawing;
-
using System.Data;
-
using System.Linq;
-
using System.Text;
-
using System.Windows.Forms;
-
using System.Diagnostics;
-
-
namespace ComboBoxControl
-
{
-
public partial class ComboBoxControl1 : ComboBox
-
{
-
private static string strcmbo = "";
-
-
#region Variables
-
-
ControlStyles styleTrue = ControlStyles.AllPaintingInWmPaint|
-
ControlStyles.DoubleBuffer |
-
ControlStyles.FixedHeight |
-
ControlStyles.ResizeRedraw |
-
ControlStyles.UserPaint;
-
private Rectangle m_clickButton;
-
private Color _ButtonBackColor;
-
-
#region Class Constructor
-
public ComboBoxControl1()
-
{
-
InitializeComponent();
-
-
SetStyle(styleTrue, true);
-
SetStyle(ControlStyles.Selectable, false); //to recive focuse if true
-
-
}
-
#endregion
-
-
#region Override Events
-
-
-
protected override void OnPaintBackground(PaintEventArgs pevent)
-
{
-
base.OnPaintBackground(pevent);
-
-
Graphics g = pevent.Graphics;
-
BorderWidth = comboBox1.Width;
-
Rectangle rect = new Rectangle(comboBox1.Location.X, comboBox1.Location.Y, BorderWidth, comboBox1.Height + 3);
-
ControlPaint.DrawBorder(g, rect, _ButtonBackColor, ButtonBorderStyle.Solid);
-
-
if (this.Text != "")
-
{
-
strcmbo = this.Text;
-
comboBox1.Text = strcmbo;
-
}
-
}
-
-
protected override void OnPaint(PaintEventArgs e)
-
{
-
-
OnPaintBackground(e);
-
OnPaintComboButton(e);
-
-
if (this.Text != "")
-
{
-
strcmbo = this.Text;
-
comboBox1.Text = strcmbo;
-
}
-
-
}
-
-
-
-
#endregion
-
-
#region Virtual Events
-
protected virtual void OnPaintComboButtonBackground(System.Windows.Forms.PaintEventArgs pevent)
-
{
-
Graphics g = pevent.Graphics;
-
Rectangle rc = ClientRectangle;
-
g.FillRectangle(new SolidBrush(BorderColor), rc.Right - 17, rc.Y + 2, 15, rc.Height - 4);
-
-
}
-
-
#endregion
-
-
}
-
}
-
this is main code when i paint combo right side button then it will black the inner color of combo?
please fine some solutions.
Is this non client area of combo box.