4

I'm getting confusion. I'm set :

this.listView1.Enabled = false;

when i make do that listview's scroll bars are disabled, too. I want to see all listviewitems in listview with scroll bars when listview disabled. Please give me some advices. Thanks.

Marco
  • 56,740
  • 14
  • 129
  • 152
Hùng Lê Xuân
  • 215
  • 1
  • 5
  • 20
  • 2
    The question is: why are you disabling listview? Do you need user can't edit items? Or what? According to this, we can provide a different solution... – Marco Dec 06 '11 at 07:13
  • There's a few ways to achieve that in [this][1] post. [1]: http://stackoverflow.com/questions/529121/wpf-disable-listbox-but-enable-scrolling – JayP Dec 06 '11 at 07:17
  • Sorry @Marco i don't need to a different solution. I'm coding multiple threading on listview and i want to see all listviewitem change on it. :) – Hùng Lê Xuân Dec 06 '11 at 07:27
  • 2
    And which is the reason you're setting `Enabled = false`? This does not help multithreading... – Marco Dec 06 '11 at 07:28
  • @JayP, I'm on Winform C#. Have you a different links. Thank. – Hùng Lê Xuân Dec 06 '11 at 07:29
  • @Marco, I have seen another .NET application do that. And my boss tell me do it. Sorry beacase I don't enough knowledge about EN to explain to you. – Hùng Lê Xuân Dec 06 '11 at 07:41
  • Hùng: you're asking us how you can disable a winforms listview because you're developing a multithreaded application writing to it. It's a nonsense. Tell us what you really need and why if you want to get helped. I'm sorry, but I think noone can do anything with those few and confused infos... – Marco Dec 06 '11 at 07:44
  • @Marco. I'm getting UI problem from multithreaded when I update information to listviewitem. So i think i should disable listview. For each listview is updated from another thread, it's 'shacked'. Sorry about i'm only use 'shacked' word for my problem. :) – Hùng Lê Xuân Dec 06 '11 at 07:54
  • Is it your listview flickering? How many items are you inserting (updating) in one second? Are you in detailed view? – Marco Dec 06 '11 at 07:57
  • yes my listview in detailed view. I have about 80.000 item. No insert here. I'm only update status for them. :) – Hùng Lê Xuân Dec 06 '11 at 08:00

4 Answers4

2

you can't scroll a disabled control, since scrollbars are part of the control itself (and it's disabled, so...).

if you want to scroll but not allow user to select anything, you could do this

this.listBox1.SelectionMode = SelectionMode.None;

if you want to revert it, you can set it to SelectionMode.One for single, or one of the other options for multiple selection allowance.

another (imho overcomplicated) option is making a user drawn ListBox.

Alex
  • 23,004
  • 4
  • 39
  • 73
2

After a lot of comments, I'm assuming your listview, because of is updated often from many different threads, is flickering.
If so, one possible solution is to enable DoubleBuffering; this property anyway is protected so accessible only from descendant classes.
So you could:

  1. Add a new class to your project and paste the code shown below
  2. Compile
  3. Drop new control from the top of the toolbox onto your form, replacing the old one

This could solve your problem.

using System;
using System.Windows.Forms;

class BufferedListView : ListView 
{
    public BufferedListView() 
    {
        this.DoubleBuffered = true;
    }
}

The idea is taken from this post on SO.

Community
  • 1
  • 1
Marco
  • 56,740
  • 14
  • 129
  • 152
1

You can't scroll a disabled control - but if you really need such a functionality, develop a user control.

Developing Custom Controls in C#

Hiding the scroll bar in CheckListbox

Writing your custom control step by step.

Sujay Ghosh
  • 2,828
  • 8
  • 30
  • 47
0

Maybe if you put your listview inside a Panel you can enable scrolling by setting up ScrollBars="Auto" on the Panel control

NicolasKittsteiner
  • 4,280
  • 1
  • 20
  • 17