Skip to content

Commit a890fee

Browse files
committed
Add logic judgment in ListBoxes.cs of the WinformsControlsTests
1 parent 6061b98 commit a890fee

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/test/integration/WinformsControlsTest/ListBoxes.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ private void ListBox_DrawItem(object sender, DrawItemEventArgs e)
4444
customBrush = Brushes.Red;
4545
}
4646

47-
e.Graphics.DrawString(listBox.Items[e.Index].ToString(),
48-
e.Font, customBrush, e.Bounds, StringFormat.GenericDefault);
47+
if (listBox.Items.Count > 0)
48+
{
49+
e.Graphics.DrawString(listBox.Items[e.Index].ToString(),
50+
e.Font, customBrush, e.Bounds, StringFormat.GenericDefault);
51+
}
4952

5053
e.DrawFocusRectangle();
5154
}

0 commit comments

Comments
 (0)