void EnsureVisible (int index)
{
if (!IsHandleCreated || index == -1)
return;
if (index < top_index) {
top_index = index;
UpdateTopItem ();
Invalidate ();
} else if (!multicolumn) {
int rows = items_area.Height / ItemHeight;
rows = rows == 0 ? 1 : rows;
if (index >= (top_index + rows))
top_index = index - rows + 1;
UpdateTopItem ();
} else {
int rows = Math.Max (1, items_area.Height / ItemHeight);
int cols = Math.Max (1, items_area.Width / ColumnWidthInternal);
if (index >= (top_index + (rows * cols))) {
int incolumn = index / rows;
top_index = (incolumn - (cols - 1)) * rows;
UpdateTopItem ();
Invalidate ();
}
}
}