StungStang 1 Posted April 19, 2011 I have an application when i can add a data from ListView...now I want to check to make sure that I don't duplicate a field when I add an item to the ListView. How do I do that? In simply word i dont want to add an item if it already exist =P For example with C# this is possible with ListView.ContainsKey...there is a way to do it in autoit? Hi! Share this post Link to post Share on other sites
UEZ 1,278 Posted April 19, 2011 (edited) Where are the values before you put it to a LV? In an array? If yes, then you can make the array unique before you put it to a LV! Br, UEZ Edited April 19, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Share this post Link to post Share on other sites
StungStang 1 Posted April 19, 2011 It's simple...i add the value with InputBox...i read the imputbox and i do a GUICtrlCreateListViewItem.hi! Share this post Link to post Share on other sites
UEZ 1,278 Posted April 19, 2011 (edited) Try this: expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 217, 266, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP)) $Input = GUICtrlCreateInput("", 8, 8, 121, 21) $Button = GUICtrlCreateButton("Add", 136, 6, 75, 25) $List = GUICtrlCreateListView("Values Added", 8, 40, 201, 214, _ BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_AUTOARRANGE, $LVS_NOSORTHEADER, $WS_VSCROLL), _ BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 175) GUISetState(@SW_SHOW) Global $aValues[1] GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button Add() EndSwitch WEnd Func Add() $value = GUICtrlRead($Input) If _ArraySearch($aValues, $value) = -1 And $value <> "" Then _ArrayAdd($aValues, $value) GUICtrlCreateListViewItem($value, $List) GUICtrlSetData($Input, "") Else MsgBox(16, "Error", "Value " & $value & " already exists!") EndIf EndFunc Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) If $iwParam = 1 Then Add() Return "GUI_RUNDEFMSG" EndFunc Br, UEZ Edited April 19, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Share this post Link to post Share on other sites