C# OwnerDrawn列表框失去焦点时为空
我订阅了C# OwnerDrawn列表框失去焦点时为空,c#,.net,winforms,listbox,ownerdrawn,C#,.net,Winforms,Listbox,Ownerdrawn,我订阅了ListBox.DrawItem事件,当它有焦点时绘制得很好,但当我离开时,它什么也不绘制 private void lbHeader_DrawItem(object sender, DrawItemEventArgs e) { e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds); e.Graphics.FillRectangle(SystemBrushes.GradientActiveCaption, e.B
ListBox.DrawItem
事件,当它有焦点时绘制得很好,但当我离开时,它什么也不绘制
private void lbHeader_DrawItem(object sender, DrawItemEventArgs e)
{
e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
e.Graphics.FillRectangle(SystemBrushes.GradientActiveCaption, e.Bounds);
int left = e.Bounds.Left + ImageList.ImageSize.Width;
for (int i = 0; i < Columns.Count; i++)
{
Rectangle textRect = Rectangle.FromLTRB(
left, e.Bounds.Top, e.Bounds.Right, e.Bounds.Bottom);
TextRenderer.DrawText(e.Graphics, "Some Text", e.Font, textRect,
FontColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
left += Columns[i].Width;
}
}
private void lbHeader\u DrawItem(对象发送方,DrawItemEventArgs e)
{
e、 Graphics.FillRectangle(SystemBrush.Window,e.Bounds);
e、 Graphics.FillRectangle(SystemBrush.GradientActiveCeption,e.Bounds);
int left=e.Bounds.left+ImageList.ImageSize.Width;
for(int i=0;i
检查此项
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index > 0)
{
e.DrawBackground();
e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), this.Font, Brushes.Black, e.Bounds);
}
}
检查这个
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index > 0)
{
e.DrawBackground();
e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), this.Font, Brushes.Black, e.Bounds);
}
}
你可以发布一些代码让我们知道你在做什么吗?显示drawitem事件背后的代码抱歉花了这么长时间,但我没有收到StackOverFlow的任何电子邮件通知。你可以发布一些代码让我们知道你在做什么吗?显示drawitem事件背后的代码抱歉花了这么长时间,但我没有收到任何电子邮件来自StackOverFlow的通知。