florisch Posted March 19, 2007 Share Posted March 19, 2007 I had a problem with GUICtrlCreateListViewItem. I created a listview with 2 columns. Later, some more colums are inserted into this listview. But when I create ListviewItems with GUICtrlCreateListViewItem that have more columns than the freshly created listview, it does not create an item. However, I can change subitems anywhere using GUICtrlSetData, so I could create a new item with 2 columns and set the rest of the data later. But thats a lot of unnescessary code. I solved the problem using _GUICtrlListViewInsertItem, which does not show such limitations. Maybe this is of interest to others, maybe sombody fixes GUICtrlCreateListViewItem, maybe someone tells me what I did wrong. Nevertheless, here is some example code: expandcollapse popup#include <GUIConstants.au3> #Include <GuiListView.au3> Global $Form1 = GUICreate("Example", 695, 700, 195, 118) Global $ListView = GUICtrlCreateListView("Status |Test", 16, 170, 530, 460, BitOR($LVS_REPORT,$LVS_NOSORTHEADER,$LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_FULLROWSELECT)) Global $BtnAdd = GUICtrlCreateButton("Add", 568, 190, 113, 30, 0) Global $BtnChange = GUICtrlCreateButton("Change 1st", 568, 240, 113, 30, 0) Global $BtnInsert = GUICtrlCreateButton("Insert", 568, 290, 113, 30, 0) GUISetState(@SW_SHOW) For $i = 1 to Random(2,5) _GUICtrlListViewInsertColumn($ListView, 1, $i & ".Test", 2, 50) Next $test = "test1" $firstItem = GUICtrlCreateListViewItem ( $test, $ListView ) While 1 ; Main loop, GUI-manager $g_msg = GUIGetMsg() Switch $g_msg Case $GUI_EVENT_CLOSE Exit Case $BtnAdd _add() Case $BtnChange _change() Case $BtnInsert _insert() EndSwitch WEnd Func _add() $test = InputBox("Test", "Please insert listviewitem data:", $test) GUICtrlCreateListViewItem ( $test, $ListView ) EndFunc Func _insert() $test = InputBox("Test", "Please insert listviewitem data:", $test) _GUICtrlListViewInsertItem($ListView, -1, $test) EndFunc Func _change() $test = InputBox("Test", "Please insert listviewitem data:", $test) GUICtrlSetData($firstItem, $test) EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now