|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Detect scroll in a ListView"roidy" <r*@nnnnnn.com> wrote in message You need to create a usercontrol derived from the listview. In this control news:vCN3m.23213$AX1.16880@newsfe20.ams2... > How do I detect when a user scrolls a ListView control? > > Thanks > Rob you will override the WndProc and raise an event when the WM_VSCROLL is sent. Follow these steps: 1. Add a new usercontrol and call it something like MyListView 2. In the MyListView.Designer.vb file change the inherits clause to: Inherits System.Windows.Forms.ListView As soon as you have done that you will see errors in the InitializeComponent sub. Just comment or delete those two lines 3. In the code file for MyListView use the following code: Public Class MyListView Public Event ProcMsg(ByVal m As Message) Public Const WM_VSCROLL As Integer = 277 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Select Case m.Msg Case WM_VSCROLL RaiseEvent ProcMsg(m) End Select MyBase.WndProc(m) End Sub End Class 4. Build your project , this will add the MyListView control to the toolbox. 5. Now add a MyListView control to your form. 6. Add code to handle the ProcMsg event. Since you didn't say what you were going to do when this occurred this is where I stop. Hope this helps LS Thanks Lloyd,
Basically my application displays a listview with 2 columns, when the user selects a row the second column has a combobox overlaid on top of it so the user can make a selection from it. Now if the user scrolls the listview I need to remove the combobox because it will no longer lineup with the selected row. I`m at step 6 in your explanation all I need to do is detect when the scroll bar is moved. I just dont know how to handle the ProcMsg event. Again thanks for the easy to follow explanation. Rob Show quoteHide quote "Lloyd Sheen" <a@b.c> wrote in message news:#R71LRP$JHA.4560@TK2MSFTNGP05.phx.gbl... > > "roidy" <r*@nnnnnn.com> wrote in message > news:vCN3m.23213$AX1.16880@newsfe20.ams2... >> How do I detect when a user scrolls a ListView control? >> >> Thanks >> Rob > > You need to create a usercontrol derived from the listview. In this > control you will override the WndProc and raise an event when the > WM_VSCROLL is sent. > > Follow these steps: > > 1. Add a new usercontrol and call it something like MyListView > 2. In the MyListView.Designer.vb file change the inherits clause to: > Inherits System.Windows.Forms.ListView > As soon as you have done that you will see errors in the > InitializeComponent sub. Just comment or delete those two lines > > 3. In the code file for MyListView use the following code: > > Public Class MyListView > Public Event ProcMsg(ByVal m As Message) > Public Const WM_VSCROLL As Integer = 277 > > Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) > Select Case m.Msg > Case WM_VSCROLL > RaiseEvent ProcMsg(m) > End Select > MyBase.WndProc(m) > End Sub > End Class > > 4. Build your project , this will add the MyListView control to the > toolbox. > > 5. Now add a MyListView control to your form. > > 6. Add code to handle the ProcMsg event. Since you didn't say what you > were going to do when this occurred this is where I stop. > > Hope this helps > LS
Show quote
Hide quote
"roidy" <r*@nnnnnn.com> wrote in message Are you saying you cannot capture the ProcMsg event. Once you have built news:GlR3m.25264$VX3.19108@newsfe14.ams2... > Thanks Lloyd, > > Basically my application displays a listview with 2 columns, when the user > selects a row the second column has a combobox overlaid on top of it so > the user can make a selection from it. Now if the user scrolls the > listview I need to remove the combobox because it will no longer lineup > with the selected row. > > I`m at step 6 in your explanation all I need to do is detect when the > scroll bar is moved. I just dont know how to handle the ProcMsg event. > > Again thanks for the easy to follow explanation. > > Rob > > "Lloyd Sheen" <a@b.c> wrote in message > news:#R71LRP$JHA.4560@TK2MSFTNGP05.phx.gbl... >> >> "roidy" <r*@nnnnnn.com> wrote in message >> news:vCN3m.23213$AX1.16880@newsfe20.ams2... >>> How do I detect when a user scrolls a ListView control? >>> >>> Thanks >>> Rob >> >> You need to create a usercontrol derived from the listview. In this >> control you will override the WndProc and raise an event when the >> WM_VSCROLL is sent. >> >> Follow these steps: >> >> 1. Add a new usercontrol and call it something like MyListView >> 2. In the MyListView.Designer.vb file change the inherits clause to: >> Inherits System.Windows.Forms.ListView >> As soon as you have done that you will see errors in the >> InitializeComponent sub. Just comment or delete those two lines >> >> 3. In the code file for MyListView use the following code: >> >> Public Class MyListView >> Public Event ProcMsg(ByVal m As Message) >> Public Const WM_VSCROLL As Integer = 277 >> >> Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) >> Select Case m.Msg >> Case WM_VSCROLL >> RaiseEvent ProcMsg(m) >> End Select >> MyBase.WndProc(m) >> End Sub >> End Class >> >> 4. Build your project , this will add the MyListView control to the >> toolbox. >> >> 5. Now add a MyListView control to your form. >> >> 6. Add code to handle the ProcMsg event. Since you didn't say what >> you were going to do when this occurred this is where I stop. >> >> Hope this helps >> LS > the project once the ProcMsg event will show in the Properties / Events window so you can attach an event handler to it. Sample code that I used to make sure this works is (the code in the sub was just there to confirm the message was being captured): Private Sub MyListView1_ProcMsg(ByVal m As System.Windows.Forms.Message) Handles MyListView1.ProcMsg This is where you would most likely set the combobox visible to false. Try Dim li As New ListViewItem("Scrolling " + m.Msg.ToString) Me.ListView1.Items.Add(li) li.EnsureVisible() Catch ex As Exception End Try End Sub Thanks Lloyd,
I didn`t realize that it had added a new ProcMsg event handler to the MyListBox properties so your right it`s as easy as adding:- Private Sub MyListView1_ProcMsg(ByVal m As System.Windows.Forms.Message) Handles MyListView1.ProcMsg ComboBox1.Hide() End Sub Thanks again for the help Rob Show quoteHide quote "Lloyd Sheen" <a@b.c> wrote in message news:eF50TGR$JHA.1380@TK2MSFTNGP02.phx.gbl... > > "roidy" <r*@nnnnnn.com> wrote in message > news:GlR3m.25264$VX3.19108@newsfe14.ams2... >> Thanks Lloyd, >> >> Basically my application displays a listview with 2 columns, when the >> user selects a row the second column has a combobox overlaid on top of >> it so the user can make a selection from it. Now if the user scrolls the >> listview I need to remove the combobox because it will no longer lineup >> with the selected row. >> >> I`m at step 6 in your explanation all I need to do is detect when the >> scroll bar is moved. I just dont know how to handle the ProcMsg event. >> >> Again thanks for the easy to follow explanation. >> >> Rob >> >> "Lloyd Sheen" <a@b.c> wrote in message >> news:#R71LRP$JHA.4560@TK2MSFTNGP05.phx.gbl... >>> >>> "roidy" <r*@nnnnnn.com> wrote in message >>> news:vCN3m.23213$AX1.16880@newsfe20.ams2... >>>> How do I detect when a user scrolls a ListView control? >>>> >>>> Thanks >>>> Rob >>> >>> You need to create a usercontrol derived from the listview. In this >>> control you will override the WndProc and raise an event when the >>> WM_VSCROLL is sent. >>> >>> Follow these steps: >>> >>> 1. Add a new usercontrol and call it something like MyListView >>> 2. In the MyListView.Designer.vb file change the inherits clause to: >>> Inherits System.Windows.Forms.ListView >>> As soon as you have done that you will see errors in the >>> InitializeComponent sub. Just comment or delete those two lines >>> >>> 3. In the code file for MyListView use the following code: >>> >>> Public Class MyListView >>> Public Event ProcMsg(ByVal m As Message) >>> Public Const WM_VSCROLL As Integer = 277 >>> >>> Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) >>> Select Case m.Msg >>> Case WM_VSCROLL >>> RaiseEvent ProcMsg(m) >>> End Select >>> MyBase.WndProc(m) >>> End Sub >>> End Class >>> >>> 4. Build your project , this will add the MyListView control to the >>> toolbox. >>> >>> 5. Now add a MyListView control to your form. >>> >>> 6. Add code to handle the ProcMsg event. Since you didn't say what >>> you were going to do when this occurred this is where I stop. >>> >>> Hope this helps >>> LS >> > > Are you saying you cannot capture the ProcMsg event. Once you have built > the project once the ProcMsg event will show in the Properties / Events > window so you can attach an event handler to it. Sample code that I used > to make sure this works is (the code in the sub was just there to confirm > the message was being captured): > > Private Sub MyListView1_ProcMsg(ByVal m As System.Windows.Forms.Message) > Handles MyListView1.ProcMsg > > This is where you would most likely set the combobox visible to false. > > Try > Dim li As New ListViewItem("Scrolling " + m.Msg.ToString) > Me.ListView1.Items.Add(li) > li.EnsureVisible() > Catch ex As Exception > End Try > End Sub >
structures in VB.Net
Add Line Break to mail body Serializing Custom Generic Collection (Of InterfaceType) OpenFileDialog and ApplicationSettings (FileName) Detect Default namespace (Unkown) Problem with System.Drawing.Bitmap() Addin to trap email item open Using Shell with Excel list of all files LINQ and Reflection |
|||||||||||||||||||||||