RaUI/Source/ryControls/Controls/ryComboBox.cs

57 lines
1.7 KiB
C#
Raw Permalink Normal View History

2020-11-28 07:03:28 +00:00
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using ryControls;
namespace ryControls
{
/// <summary>
///
/// </summary>
[ToolboxBitmap(typeof(System.Windows.Forms.ComboBox))]
public partial class RyComboBox : System.Windows.Forms.ComboBox
{
/// <summary>
///
/// </summary>
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);
});
}
/// <summary>
/// 绘制边框
/// </summary>
/// <param name="m">消息</param>
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));
}
}
}
}