开发者

Hide Vertical Scrollbar/Sync Top Item with Scrollable = false

开发者 https://www.devze.com 2023-03-31 22:14 出处:网络
I\'m trying to sync up 2 list views, so that one of them is effectively a \'freeze pane\' of one column (think excel freeze-headers).

I'm trying to sync up 2 list views, so that one of them is effectively a 'freeze pane' of one column (think excel freeze-headers).

However, I am having difficulty in getting the top items to sync up when scrolling. I need to hide the vertical and horiz开发者_如何学Pythonontal scrollbars on the header-list view, which can be achieved by setting Scrollable to false. Though this seems to disable the 'EnsureVisible' and 'TopItem' functionality?

I have intercepted the scroll bar messages on the master listview, so I know when that is being scrolled, just for some reason I'm unable to update the top item on the header listview to match up.

The code I have for updating the header listview is as follows:

//On vertical scroll click...
  if (e.Type == ScrollEventType.EndScroll)
  {
    int index = lvwHeader.FindItemWithText(lvwSource.TopItem.Text).Index;

    ListViewItem item = lvwHeader.Items[index];
    lvwHeader.TopItem = item;

    System.Diagnostics.Debug.WriteLine(lvwHeader.TopItem.Text + " - " + lvwSource.TopItem.Text);
  }

So I was wondering if there was another way to force the header listview to set an item as the topitem whilst Scrollable = false, or if there was a better way to approach this?

Many thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号