DevExpress
2014.05.13 10:05
리스트 박스에서 아이템 내용에 New Line이 들어가는 경우 Height조정을 자동화 하는 방법
다물칸 주소복사
조회 수 549 추천 수 0 댓글 0
구분 | 팁&트릭 |
---|---|
출처 | https://documentation.devexpress.com/#windowsforms/CustomDocument9495 |
private void lstLog_MeasureItem(object sender, MeasureItemEventArgs e) { if (lstLog.Items.Count <= 0) return; ListBoxControl lb = sender as ListBoxControl; string itemValue = (string)lb.Items[e.Index]; if (itemValue.Contains("\r\n")) { e.ItemHeight = e.ItemHeight * 2; } else if (itemValue.Contains("\r")) { e.ItemHeight = e.ItemHeight * 2; } else if (itemValue.Contains("\n")) { e.ItemHeight = e.ItemHeight * 2; } }
출처에도 있지만 그대로 하면 에러 발생할 수도 있어서 예외처리와 Line feed, CR도 같이 처리할 수 있도록 추가하였습니다.