By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,127 Members | 1,150 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,127 IT Pros & Developers. It's quick & easy.

listview scrollbars removing or user control

P: n/a
I have basically a 2 part question:

1) is there a way to have a listview that can scroll, but hide the
scrollbars. I know that sounds odd, but this is a touch screen app
and there are "scroll buttons (just command buttons with graphic)"
that go to the next/previous item in the list and that allows the
scrolling. I know they can drag the scroll bar down by touching, but
that causes me a problem when the selected item goes out of view (see
item 2 below). The only way I found was to turn scrollable=false, but
that caused the list to not be able to go past the display no matter
what was in the list, even when using the ensurevisible method.

2) The other option I have is catching the scroll message by
overriding the WndProc and calling ensurevisible on the selected item.
However to do that, I think (and correct me if I'm wrong) I need to
create a new Listview that inherits from the .net listview and put the
override in that class. I've never done that before, so do I have to
create a User Control, Inherited control, or what ? Does it have to
be in its own .dll so it can be referenced or can it reside in the
main project itself ? Basically, I dont have a real good feel for
this aspect yet.

Or maybe there are other ways to accomplish what I need ?

Many TIA,
Mark
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Sorry, you should also include this in code for classes that inherit from
controls (otherwise InitializeComponent will never be called):

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub
Nov 21 '05 #2

P: n/a
Thanks for the example. It's very helpful.

As far as the project that uses this, I would build an Inherited
Control project, compile this to a .dll, then use it on my form ? Is
that the correct way to do it ?
"ljlevend" <lj******@discussions.microsoft.com> wrote in message news:<B6**********************************@microso ft.com>...
I highly recommend that you familiarize yourself with inheritance. Here is a
sample for how to inherit from ListView. Note that I’ve overridden the
OnLayout, WndPrc, and Dispose methods.

Public Class ListViewAdv
Inherits Windows.Forms.ListView

'Add this to any class that inherits from a control.
#Region " Windows Form Designer generated code "

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'ListViewAdv
'
Me.Name = "ListViewAdv"

End Sub

#End Region

Protected Overrides Sub OnLayout(ByVal levent As
System.Windows.Forms.LayoutEventArgs)
'Add your code here.

'Call the base method.
Call MyBase.OnLayout(levent)

'Or, add your code here.
'
'TEST CODE
Debug.WriteLine("OnLayout")
'
End Sub

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
'Add your code here.

'Call the base method.
Call MyBase.WndProc(m)

'Or, add your code here.
'
'TEST CODE
Debug.WriteLine(System.String.Format("WndProc: {0}", m.ToString))
'
End Sub

'Add this to any class that inherits from a control.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
End Class

Hope this helps.
Lance

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.