Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# OwnerDrawn列表框失去焦点时为空_C#_.net_Winforms_Listbox_Ownerdrawn - Fatal编程技术网

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的通知。