我想知道是否有办法在我的订单项之间添加填充。这是一种用于平板电脑的表单,每个表单之间的空间可以让您更轻松地选择不同的项目。
有人知道我该怎么做吗?
有一个ItemHeight
财产。
你必须改变DrawMode
财产给OwnerDrawFixed
使用自定义ItemHeight
.
当你使用DrawMode.OwnerDrawFixed
您必须“手动”绘制/绘制项目。
这是一个例子:组合框外观 https://stackoverflow.com/questions/3789596/combobox-appearance
上面链接中的代码(由以下人员编写/提供)max https://stackoverflow.com/users/356716/max):
public class ComboBoxEx : ComboBox
{
public ComboBoxEx()
{
base.DropDownStyle = ComboBoxStyle.DropDownList;
base.DrawMode = DrawMode.OwnerDrawFixed;
}
protected override void OnDrawItem(DrawItemEventArgs e)
{
e.DrawBackground();
if(e.State == DrawItemState.Focus)
e.DrawFocusRectangle();
var index = e.Index;
if(index < 0 || index >= Items.Count) return;
var item = Items[index];
string text = (item == null)?"(null)":item.ToString();
using(var brush = new SolidBrush(e.ForeColor))
{
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
e.Graphics.DrawString(text, e.Font, brush, e.Bounds);
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)