using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Windows.Forms; using ryControls; namespace ryControls { /// /// /// [ToolboxBitmap(typeof(System.Windows.Forms.ComboBox))] public partial class RyComboBox : System.Windows.Forms.ComboBox { /// /// /// public RyComboBox() : base() { base.DoubleBuffered = true; base.FlatStyle = FlatStyle.Flat; base.DrawMode = DrawMode.OwnerDrawFixed; base.DrawItem += new DrawItemEventHandler(delegate (object sender, DrawItemEventArgs e) { if (e.Index < 0) { return; } StringFormat stringFormat = new StringFormat { LineAlignment = StringAlignment.Center }; e.DrawBackground(); e.DrawFocusRectangle(); SizeF size= e.Graphics.MeasureString(base.Items[e.Index].ToString(),e.Font); float kk = e.Bounds.Y + (e.Bounds.Height - (int)size.Height); e.Graphics.DrawString(base.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X,kk); }); } /// /// 绘制边框 /// /// 消息 protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == 0xf || m.Msg == 0x133) { ryControls.SkinHelp.ResetBorderColor(m, this, 1, Color.FromArgb(213, 216, 223)); } } } }