|
-
Jan 30th, 2008, 06:16 AM
#1
Thread Starter
Frenzied Member
[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
-
Jan 30th, 2008, 06:52 AM
#2
Addicted Member
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
-
Jan 30th, 2008, 07:09 AM
#3
Re: Not record in the listview
If there is nothing in the ListView, disable the Move button.
-
Jan 30th, 2008, 09:09 AM
#4
Lively Member
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.
-
Jan 30th, 2008, 09:38 AM
#5
Thread Starter
Frenzied Member
Re: Not record in the listview
 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.
-
Jan 30th, 2008, 09:44 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|