다음 코드를 사용하여 ListBox 내의 각 목록 항목을 재정의하고 그립니다.어떻게 ListBox의 드롭 다운 영역에 테두리를 추가 할 수 있습니까?
if (e.Index < 0) return;
// if the item state is selected then change the back color
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
e = new DrawItemEventArgs(e.Graphics,
e.Font,
e.Bounds,
e.Index,
e.State^DrawItemState.Selected,
e.ForeColor,
Color.Red); // Choose the color
// Draw the background of the ListBox control for each item.
e.DrawBackground();
// Draw the current item text
e.Graphics.DrawString(studentsListBox.Items[e.Index].ToString(), e.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
// If the ListBox has focus, draw a focus rectangle around the selected item.
e.DrawFocusRectangle();
코드는 내가 생각하는 것처럼, 그러나 나는 또한 목록 상자의 전체 드롭 다운 부분에 테두리를 추가 할 작품이다 (아래 예제 이미지를 참조하십시오.) 나는 국경을 추가 할 수있는 방법 전체 목록에? 제목이 경계를 참조하기 때문에
두 가지 질문을하고 있습니다. 어떻게 드롭 다운 목록에 테두리를 그릴 수 있으며 목록의 각 요소 모양을 어떻게 수정할 수 있습니까? 질문의 성격을 반영하여 질문을 업데이트하거나 두 가지 별도의 SO 질문을하십시오. 고맙습니다. – RLH
@RLH 제 질문을 수정 해 주시겠습니까?이 질문에 답해 주시겠습니까? –