0

I have a listview that I am owner drawing the column headers, sub items and items. My problem is when I draw the column header it does not draw the background past the last actual column. I am left with a space with the default column header background when there are not enough items in the list view to show the vertical scroll bar.

Is there a way I can paint the background of this space or permanently show the vertical scroll bar?

Here is a picture of my issue. The code I am trying to use actually is compiling, but when I try to call the method I get a TypeLoadException saying the method 'ShowScrollBar' has no implementation.

[DllImport("user32.dll")]
static extern int ShowScrollBar(IntPtr hWnd, int wBar, bool bShow);
Alex
  • 870
  • 2
  • 9
  • 19
  • Permanently showing the vertical scrollbar is tricky but apparently possible, see here: http://stackoverflow.com/questions/8690643/how-to-force-vertical-scrollbar-always-be-visible-from-autoscroll-in-winforms – demoncodemonkey Sep 01 '14 at 23:02
  • I tried that. When I run the application it does not recognize that method and stops compiling. Did some more research and I have it correct, but it still won't let me compile. – Alex Sep 02 '14 at 05:23
  • If it doesn't compile you don't have it right. Add the code you have to the answer and we'll see.. – TaW Sep 02 '14 at 13:56
  • @TaW, I added the code to my question. – Alex Sep 03 '14 at 00:39
  • I fooled around with my code. I had the DllImport and the ShowScrollBar method in a custom class. This is when I get the TypeLoadException. If I move the method and its DllImport into the form code I do not get an exception. But the method still does not work. It complies fine but it does not keep the scroll bar there always. If I can get the method to work, I would rather have it in my custom class so other forms can call it without adding it to each forms code. – Alex Sep 03 '14 at 01:06
  • Please also add the code that calls ShowScrollBar! – TaW Sep 03 '14 at 06:41
  • @TaW, ShowScrollBar(listTodaysCalls.Handle, 1, true); – Alex Sep 03 '14 at 06:59

1 Answers1

0

My way of solving this issue was to switch to a DataGridView. Much more customizable and I only need details view. If anyone else has this problem, make the switch. You won't regret it.

Alex
  • 870
  • 2
  • 9
  • 19