日期:2014-05-19  浏览次数:20678 次

大家有没有象Windows地址栏这样的Combox源码。
大家有没有象Windows地址栏这样的Combox源码。
共享一下。

------解决方案--------------------
//参考如下代码
//设置comboBox1.DrawMode = OwnerDrawFixed;

private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
Point vPoint = e.Bounds.Location;
vPoint.Offset(e.Index * 8, 0);
e.DrawBackground();
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
imageList1.Draw(e.Graphics, vPoint, 0);
vPoint.Offset(imageList1.ImageSize.Width + 2, 2);
e.Graphics.DrawString(((ComboBox)sender).Items[e.Index].ToString(), e.Font,
SystemBrushes.HighlightText, vPoint);
}
else
{
imageList1.Draw(e.Graphics, vPoint, 1);
vPoint.Offset(imageList1.ImageSize.Width + 2, 2);
e.Graphics.DrawString(((ComboBox)sender).Items[e.Index].ToString(), e.Font,
SystemBrushes.MenuText, vPoint);
}
}