Results 1 to 6 of 6

Thread: [RESOLVED] Not record in the listview

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] Not record in the listview

    I got error while try to move the highlighted in the listvew when no record in the listview. How I can ask the user that no record in the listview if they to push the move button?

    Code:
    Private Sub Command8_Click()
    If ListView1.SelectedItem.Index = 1 Then
    Set ListView1.DropHighlight = ListView1.SelectedItem
    ListView1.SelectedItem.EnsureVisible
    Command8.Enabled = False
    Else
    'bila di akhir
    If ListView1.SelectedItem.Index = ListView1.ListItems.Count Then
    
        Set ListView1.SelectedItem = ListView1.ListItems(ListView1.SelectedItem.Index - 1)
        Set ListView1.DropHighlight = ListView1.SelectedItem
        ListView1.SelectedItem.EnsureVisible
    Command9.Enabled = True
    Else
    Command9.Enabled = True
        Set ListView1.SelectedItem = ListView1.ListItems(ListView1.SelectedItem.Index - 1)
        Set ListView1.DropHighlight = ListView1.SelectedItem
        ListView1.SelectedItem.EnsureVisible
    End If
    End If
    End Sub

  2. #2
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: Not record in the listview

    For checking whether no items is available in the List control, try check with "-1" against the List count.

    If this does not solve, can you brief what is your clear requirement so that look for the workaround?
    Regards
    Srinivasan Baskaran
    India

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Not record in the listview

    If there is nothing in the ListView, disable the Move button.

  4. #4
    Lively Member
    Join Date
    Jul 2007
    Posts
    98

    Re: Not record in the listview

    declare a private(for the module) variable m_objSelectedItem as ListItem.

    When the user clicks on Item set the variable to the item passed by the Item_Click event
    and edit the Enabled/Disabled properties of the buttons you use to manage the ListView

    Then everywhere where you have an SeletedItem processing add :

    If Not m_objSelectedItem is nothing then
    'do your processing here

    end if

    Don't forget to handle the m_objSelectedItem correct - every time the user moves/deletes the selected item this variable must be reinitialized. It must be initialized to Nothing on load. Same gilts for the Enabled/Disabled properties of the buttons you use to manage the ListView.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Not record in the listview

    Quote Originally Posted by Hack
    If there is nothing in the ListView, disable the Move button.
    I am prefer to this solution. How to set when the is nothing in the listview, then common button disable. I don't know how to code like this. Any clue so that I can go further.

  6. #6
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Smile Re: Not record in the listview

    Code:
    If listview1.Listitems.count = 0 then
        command1.enabled = false
    End if

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width