How to move the project up and down in the ListView control (VFP)
001: 001:
Function MoveliStItem 002: * - Features: How to Move Projects Upon Upper Lower Control (VFP) in the ListView Control
003: * - Author: Red Tiger
004: * - Parameter: For the ListView control, and the direction (1 = down, -1 = up, other parameters return)
005: * - Back: None
006:
LParameters TolistView As Mscomctllib.listView, Tnarrow AS Integer 007:
008:
Local LOLIST AS MSCOMCTLLIB.LISTVIEW 009:
LOLIST = TOListView 010:
011:
Local LoItem AS MSComctllib.listItem 012:
Local LonewItem AS MScomctllib.listItem 013:
014: * - Project that current ListView selection
015:
LoItem = lolist.selectedItem 016:
017: * - Judgment the selected item
018:
IF Isnull (LoItem) 019:
Return 020:
ENDIF 021:
022: * - Decision parameter is 1 or -1
023:
IF Type ("tnarrow") # "n" 024:
tnarrow = 0 025:
ENDIF 026:
Do Case 027:
Case tnarrow = 1 && down 028:
If Loitem.index = LOLIST.LISTITEMS.COUNT 029:
?? CHR (7) 030:
Return 031:
ENDIF 032:
Case tnarrow = -1 && up 033:
If Loitym.index = 1 034:
?? CHR (7) 035:
Return 036:
ENDIF 037:
OtherWise 038:
?? CHR (7) 039:
Return 040:
Endcase 041:
042: * - Define variables required for projects
043:
Local lasublistItemtemtext (1) AS STRING 044:
Local LNTOTALSUBITEMS AS INTEGER 045:
Local n as integer 046:
Local lnitemindex as integer,; 047:
LCITEMKEY As String,; 048:
LcitemText As string,; 049:
Lcitemtag as string,; 050:
Lusmallicon As Variant ,; 051:
Llchecked As Boolean 052:
053: * - Get the data of the selected item
054:
With loitem 055:
lnitemindex = .index Tnarrow 056:
LcitemKey = .key 057:
LcitemText = .text 058:
LcitemTag = .tag 059:
Lusmallicon = .smallicon 060:
LNTOTALSUBITEMS = .ListSubitems.count 061:
LlChecked = .checked 062:
063:
Local lasublistItemText (LNTOTALSUBITEMS) AS STRING 064: for n = 1 To LNTOTALSUBITEMS 065:
LasublistItemText (n) = .ListSubitems (N) 066:
NEXT 067:
ENDWITH 068:
069: * - Remove the item after getting
070:
Lolist.listItems.Remove (LoItem.index) 071:
072: * - Add new project and specify its index value
073:
LONEWITEM = LOLIST.LIStItems.Add (LniteMindex, LcitemKey, LcitemText, Lusmallicon) 074:
075: * - Assignment of new projects based on the original data selected by the project selected
076:
WITH LONEWITEM 077:
.Tag = lcitemtag 078:
For n = 1 to LNTOTALSUBITEMS 079:
. ListSubitems.add (, LasublistItemtext (n)) 080:
NEXT 081:
.Selected = .t. 082:
.Checked = llchecked 083:
.Ensurevisible () 084:
ENDWITH 085:
086:
Lolist.setfocus () 087:
088: Endfunc