Listview (Button)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 15 of 15

Thread: Listview (Button)

  1. #1
    Join Date
    Jul 2007
    Posts
    46

    Question Listview (Button)

    I would like to create up/down button for listview rows up/down instade of
    using scrollbar, since we are usring touch screen and scrollbar with is vey small.

    Thanks

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Can't you navigate your listview using the arrow keys?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Jul 2007
    Posts
    46
    as I mentioned the scrollbar in the listview in very thin and we are using touch screen that why we need button for up/down. or there is any way to enlarge arrow key?

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    No, no, I don't mean the arrow key on the listview itself, I mean the arrows keys on the keyboard.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    Jul 2007
    Posts
    46
    I have the following code in .NET can any one convert it to VB6.

    ' Up and Down Button Handlers.

    Private Sub btnUp_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnUp.Click
    Me.MoveListViewItem(Me.lvRegions, moveUP:=True)
    End Sub

    Private Sub btnDown_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnDown.Click
    Me.MoveListViewItem(Me.lvRegions, moveUP:=False)
    End Sub

    Private Sub MoveListViewItem(ByRef lv As ListView, ByVal moveUp As Boolean)
    Dim i As Integer
    Dim cache As String
    Dim selIdx As Integer

    With lv
    selIdx = .SelectedItems.Item(0).Index
    If moveUp Then
    ' ignore moveup of row(0)
    If selIdx = 0 Then
    Exit Sub
    End If
    ' move the subitems for the previous row
    ' to cache so we can move the selected row up
    For i = 0 To Items(selIdx).SubItems.Count - 1
    cache = .Items(selIdx - 1).SubItems(i).Text
    .Items(selIdx - 1).SubItems(i).Text = _
    .Items(selIdx).SubItems(i).Text
    .Items(selIdx).SubItems(i).Text = cache
    Next
    .Items(selIdx - 1).Selected = True
    .Refresh()
    .Focus()
    Else
    ' ignore move down of last row
    If selIdx = .Items.Count - 1 Then
    Exit Sub
    End If
    ' move the subitems for the next row
    ' to cache so we can move the selected row down
    For i = 0 To Items(selIdx).SubItems.Count - 1
    cache = .Items(selIdx + 1).SubItems(i).Text
    .Items(selIdx + 1).SubItems(i).Text = _
    .Items(selIdx).SubItems(i).Text
    .Items(selIdx).SubItems(i).Text = cache
    Next
    .Items(selIdx + 1).Selected = True
    .Refresh()
    .Focus()
    End If
    End With
    End Sub


    Thanks
    Last edited by kafsar; 02-04-2008 at 09:57 AM.

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I would use standard command buttons. Use this code to scroll the listview up or down: http://www.devx.com/vb2themax/Tip/19271
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Why do you want to move from .NET back to VB6?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  8. #8
    Join Date
    Jul 2007
    Posts
    46

    Question

    Quote Originally Posted by Phil Weber
    I would use standard command buttons. Use this code to scroll the listview up or down: http://www.devx.com/vb2themax/Tip/19271

    I need only vertically scroll and there is a one colum only. can you modify code as my need with two command buttons up/down

    Thanks

  9. #9
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Hack: He's not using .NET; he found a .NET sample and wants to use the technique with his VB6 application.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  10. #10
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    kafsar: You don't need to modify the code, just pass zero (0) for the dx parameter.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  11. #11
    Join Date
    Jul 2007
    Posts
    46

    Question

    Quote Originally Posted by Phil Weber
    kafsar: You don't need to modify the code, just pass zero (0) for the dx parameter.
    I realy don't have much exp., can you gine any example to call this function from button.

    Function ListViewScroll(lvw As ListView, ByVal dx As Long, ByVal dy As Long)
    SendMessage lvw.hwnd, LVM_SCROLL, dx, ByVal dy
    End Function

    thanks

  12. #12
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Do you have the declares for SendMessage and LVM_SCROLL?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  13. #13
    Join Date
    Jul 2007
    Posts
    46

    Question

    Ok,, Thanks problem solved

    Thanks for support
    Last edited by kafsar; 02-05-2008 at 07:18 AM.

  14. #14
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Please post your solution as it might help someone else with the same or similiar situation.

    Thanks.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  15. #15
    Join Date
    Jul 2007
    Posts
    46

    Talking

    Quote Originally Posted by Hack
    Please post your solution as it might help someone else with the same or similiar situation.

    Thanks.
    Here is solution.
    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
    hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    lParam As Any) As Long
    Const LVM_FIRST = &H1000
    Const LVM_SCROLL = (LVM_FIRST + 20)
    
    Function ListViewScroll(lvw As ListView, ByVal dx As Long, ByVal dy As Long)
    SendMessage lvw.hwnd, LVM_SCROLL, dx, ByVal dy
    End Function
    
    Private Sub cmdUP_Click()
    Call ListViewScroll(ListView2, 0, -50)
    End Sub
    
    Private Sub cmdDown_Click()
    Call ListViewScroll(ListView2, 0, 50)
    End Sub
    Last edited by kafsar; 02-05-2008 at 10:22 AM. Reason: Added Code Tags

Similar Threads

  1. Replies: 7
    Last Post: 07-17-2013, 12:47 AM
  2. Replies: 5
    Last Post: 12-16-2008, 12:02 PM
  3. Replies: 1
    Last Post: 09-16-2006, 08:37 PM
  4. Need help with calculator...
    By 2eXtreme in forum Java
    Replies: 0
    Last Post: 04-05-2006, 08:38 AM
  5. button listener not working
    By DrunkinP in forum Java
    Replies: 0
    Last Post: 03-31-2005, 10:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center