Editing a multicolumn ListView

G

Guest

Hello

I need to allow users to freely edit a multicolumn list. (I'm using a
ListView specifically because it can be induced to scroll when a user
"nudges" the top or bottom with the mouse.) To allow users to edit fields I
throw up a Textbox over the selected field. (The ListView has facilities for
editing the first column, but I need all columns to be editable.) It works
unless the user scrolls the ListView while the editable Textbox has the focus
-- in this case the editable box stays where it is while the background
scrolls out from under it.

Is there a way I can 'pin' the Textbox to the ListView client, or at least
detect when the ListView is scrolled, so I can validate and hide the TextBox?

Thanks
 
J

Jared

detect when the ListView is scrolled,

See class below, I found it on internet and have modified it so it works
when half visible item is clicked as well.

Also, you will need to update designer in 2 spots, from ListView to
xListView. If you have any problem with that just reply.

Public Class xListView

'NOTE take from internet somewhere - pureley to capture topitem change from
scroll

' - but has proven to be helpfull on half item click as well



Inherits Windows.Forms.ListView



Private Const WM_VSCROLL As Integer = &H115



Enum ScrollBarActions As Integer

SB_LINEUP = &H0

SB_LINEDOWN = &H1

SB_PAGEUP = &H2

SB_PAGEDOWN = &H3

SB_THUMBPOSITION = &H4

SB_THUMBTRACK = &H5

SB_TOP = &H6

SB_BOTTOM = &H7

SB_ENDSCROLL = &H8

End Enum



Event IMovedEvent()



Private Var1() As String

Private Var2() As String



Protected Overrides Sub wndProc(ByRef m As Message)

'HACK fix attempt for selcting bottem item which is split

With m.WParam

If m.Msg.Equals(&H115) And .ToInt32 = ScrollBarActions.SB_ENDSCROLL Then

RaiseEvent IMovedEvent()

End If

'MESSAGE = SCROLLED, BUT ACTS LIKE SELECTED INDEX CHANGE(SINGULAR)

If m.Msg.Equals(&H113) Then

RaiseEvent IMovedEvent()

End If

End With

MyBase.WndProc(m)

End Sub

Private Sub xListView_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

Select Case e.KeyCode

Case Keys.Up, Keys.Down, Keys.PageDown, Keys.PageUp

Console.WriteLine("Raising IMovedEvent")

RaiseEvent IMovedEvent()

End Select

End Sub



End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top