[已解决]有没有函数 可以把 ListView 上面所有的内容一次写到 数组里面的??
本帖最后由 kk_lee69 于 2012-11-19 15:53 编辑_GUICtrlListView_AddArray 可以把陣列一次寫到LISTVIEW
那麼 有没有函数 可以把 ListView 上面所有的内容一次写到 数组里面的?? 回复 1# kk_lee69
咋不你来写一个造福大众??
那个也是个自定义函数而已 了解 本來是想說 是不是 有我不知道的方法.....看來還是得 算 行數 算列數 然後再定義數組 跑循環 加入進去了 呵呵, 感謝回覆!! 一般在生成列表项之前或同时就可同步更新到数组(或副本),可随时按需使用。 本帖最后由 netegg 于 2012-11-18 12:37 编辑
; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlListView_CreateArray
; Description ...: Creates a 2-dimensional array from a lisview.
; Syntax ........: _GUICtrlListView_CreateArray($hListView[, $sDelimeter = '|'])
; Parameters ....: $hListView - Control ID/Handle to the control
; $sDelimeter - One or more characters to use as delimiters (case sensitive). Default is '|'.
; Return values .: Success - The array returned is two-dimensional and is made up of the following:
; $aArray = Number of rows
; $aArray = Number of columns
; $aArray = Delimited string of the column name(s) e.g. Column 1|Column 2|Column 3|Column nth
; $aArray = 1st row, 1st column
; $aArray = 1st row, 2nd column
; $aArray = 1st row, 3rd column
; $aArray = nth row, 1st column
; $aArray = nth row, 2nd column
; $aArray = nth row, 3rd column
; Author ........: guinness
; Remarks .......: GUICtrlListView.au3 should be included.
; Example .......: yes
; ===============================================================================================================================
Func _GUICtrlListView_CreateArray($hListView, $sDelimeter = '|')
Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView), $iDim = 0, $iItemCount = _GUICtrlListView_GetItemCount($hListView)
If $iColumnCount < 3 Then
$iDim = 3 - $iColumnCount
EndIf
If $sDelimeter = Default Then
$sDelimeter = '|'
EndIf
Local $aColumns = 0, $aReturn[$iItemCount + 1][$iColumnCount + $iDim] = [[$iItemCount, $iColumnCount, '']]
For $i = 0 To $iColumnCount - 1
$aColumns = _GUICtrlListView_GetColumn($hListView, $i)
$aReturn &= $aColumns & $sDelimeter
Next
$aReturn = StringTrimRight($aReturn, StringLen($sDelimeter))
For $i = 0 To $iItemCount - 1
For $j = 0 To $iColumnCount - 1
$aReturn[$i + 1][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j)
Next
Next
Return SetError(Number($aReturn = 0), 0, $aReturn)
EndFunc ;==>_GUICtrlListView_CreateArray 用循环一个一个加吧。 贡献是怎么来的???怎么我是-4???? 向高手学习 有用,顶一下 感谢5楼分享!
_GUICtrlListView_CreateArray
页:
[1]