Determining if ListView scrollbars are visible?

0
0

It seems VB handles listviewColumn.Width = -1, but not C#.  So I am redoing my listview column sizing code.  These contain HTML and I would like them to be set to the maximum available space of the Listview.

lv.AutoResizeColumn() has no AutoResizeStyle to do available area, so I am trying to do it numerically via extension method.

 

public static void SetFirstColumnWidthToMax(this Wisej.Web.ListView lv)
{
lv.Columns[0].Width = lv.Width – 24;
}

the problem is, sometimes a vertical scrollbar is showing, and sometimes not — thus I need to account for it.  Is there a way to check if the vertical scrollbar is visible? Or is there an easier way to do this?  Thanks

Andrew

  • You must to post comments
0
0

This is what I have for now.  Column height may be different depending on your theme.

 

public static bool IsVerticalScrollbarOn(this Wisej.Web.ListView lv)
{
//get total row height, if higher than lv.height + column height, return true
int itemHeightTotal = 0;
for (int i =0; i < lv.Items.Count; i++)
{
itemHeightTotal += lv.Items[i].RowHeight;
}

int columnHeight = 33;
int totalHeight = columnHeight + itemHeightTotal;

return totalHeight > lv.Height;
}

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.