Jump to content
Sign in to follow this  
FireLordZi

Create ListViewItem

Recommended Posts

FireLordZi

When I create a listview item here:

For $value In $splitit
    If $value <> "" Then GUICtrlCreateListViewItem($value, $sListview); Creates the listview items from the INI file
 Next

at the very top of the listview there is a number 2, which 2 is how many listview items I have.

How can I get rid of it?

Full Code:

$itemID = _GUICtrlListViewGetCurSel($nListview)
                 $buddyText = _GUICtrlListViewGetItemText($nListview, $itemID, 1); Get the item ID of selected item
                 $itemName = INIRead("C:\buddies.ini", "OnlineBuddies", $buddyText, "")
                 $splitit = StringSplit($itemName, ","); Splits the strings
                 If $itemName = "" Then
                     _GUICtrlListViewDeleteAllItems($sListview)
                     GUICtrlCreateListViewItem("Offline", $sListview)
                 Else
                     _GUICtrlListViewDeleteAllItems($sListview)
                     $itemName = INIRead("C:\buddies.ini", "OnlineBuddies", $buddyText, ""); Reads key
                     $splitit = StringSplit($itemName, ",")
                     For $value In $splitit - 1
                        If $value <> "" Then GUICtrlCreateListViewItem($value, $sListview); Creates the listview items from the INI file
                     Next
                 EndIf
Edited by FireLordZi

While Alive() {
	 DrinkWine();
}
AutoIt Programmer

Share this post


Link to post
Share on other sites
Thatsgreat2345

Since splitit is just an array, I recommend using

For $i = 1 to Ubound( $splitit) - 1
    If Not ($splitit[$i] = '') Then GUICtrlCreateListViewItem($splitit[$i], $sListview); Creates the listview items from the INI file
Next

That is how I prefer doing it with arrays to using in. I usually only use in for objects.

Edited by Thatsgreat2345

Share this post


Link to post
Share on other sites
FireLordZi

Thanks. That solved the problem 8)


While Alive() {
	 DrinkWine();
}
AutoIt Programmer

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.