Jump to content

Problem with Listview


FireLord
 Share

Recommended Posts

I have two columns in my listview. If at the beginning of my script it executes certain code and puts something in column two and later on it executes code and needs to put something right beside what it just did except in the first column, would I just do GUICtrlCreateListViewItem("whatever", $nListview)? Because when I do it ends up in column one, but it is below the listview item that was created at the beginning of my script. Why?

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

I have two columns in my listview. If at the beginning of my script it executes certain code and puts something in column two and later on it executes code and needs to put something right beside what it just did except in the first column, would I just do GUICtrlCreateListViewItem("whatever", $nListview)? Because when I do it ends up in column one, but it is below the listview item that was created at the beginning of my script. Why?

Aren't the function names self-explanatory?

GUICtrlCreateListViewItem creates a new item (row) in a listview.

To modify text of a listview item - GUICtrlSetData.

"be smart, drink your wine"

Link to comment
Share on other sites

Aren't the function names self-explanatory?

GUICtrlCreateListViewItem creates a new item (row) in a listview.

To modify text of a listview item - GUICtrlSetData.

Thanks. Head isn't clear today.

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

hi,

#include <GUiconstants.au3>

GUICreate(":-)",320,250, 100,200)
$Listview = GUICtrlCreateListView ("col1          |col2           ",10,10,300,150)
$additem = GUICtrlCreateButton ("Add New Item",10,170,300,20)
$addcol1 = GUICtrlCreateButton ("Set selected item data Column 1",10,195,300,20)
$addcol2 = GUICtrlCreateButton ("Set selected item data Column 2",10,220,300,20)
GUISetState()

While 1
    $gMsg=GUIGetMsg()
    Switch $gMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $additem
            GUICtrlCreateListViewItem("", $Listview)
            GUICtrlSetState(-1, $GUI_FOCUS)
        Case $addcol1
            GUICtrlSetData(GUICtrlRead($Listview), "Column 1")
        Case $addcol2
            GUICtrlSetData(GUICtrlRead($Listview), "|Column 2")
    EndSwitch
WEnd

Cheers

Edited by smashly
Link to comment
Share on other sites

Aren't the function names self-explanatory?

GUICtrlCreateListViewItem creates a new item (row) in a listview.

To modify text of a listview item - GUICtrlSetData.

I did GUICtrlSetData($nListview, "Yes") and now it's not even showing up in the listview.

What I'm aiming to do is to read an INI's values (that part is flawless) and take each one

and enter them into an input in another window. I'm trying to get each one entered in the

window one-by-one and then if the other window replies with a msgbox then I want to write

the word "No" in the listview next to the name that I just entered. Here's what i have so far but

parts of it don't work.

If WinExists("Window App", "" ) Then
                WinActivate("Window App", "")
                Send("{CTRLDOWN}{f}")
                Send("{CTRLUP}")
                $buddiesSearch = StringSplit($var, ",")
            ;Check if any words found
                If WinExists("Find", "") Then
                If IsArray($buddiesSearch) Then
                For $i = 1 To $buddiesSearch[0]
                    Send($buddiesSearch[$i] & ControlClick("Find", "", 258));Clicks the search button on the window
                    If WinActive("[CLASS:32770]", "") Then; If msgbox appears then...
                        GUICtrlSetData($nListview, "No") 
                    Else
                        GUICtrlSetData($nListview, "Yes")
                    EndIf                   
            Next
        EndIf
    Else
        MsgBox(0, "", "Unable to search.")
    EndIf
            Else
                MsgBox(16, "Error", "Window App isn't even running!")
            EndIf

:P

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

The reason your having trouble with GUICtrlSetData($nListview, "Yes") in your listview,

GUICtrlSetData() is meant for internal use on an Autoit created listview control that's been created by Autoit in the current running script..

In your first post you didn't mention an external listview control generated by another application was what you were trying to set data in.

Maybe look at using UDF listview functions from a current Autoit beta to accomplish what your after.

And/Or

Have a look at ControlSetText() instead maybe

Cheers

Edit: If your not calling an external listview then NO you haven't provided enough of a script to locate your errors..

Edited by smashly
Link to comment
Share on other sites

The reason your having trouble with GUICtrlSetData($nListview, "Yes") in your listview,

GUICtrlSetData() is meant for internal use on an Autoit created listview control that's been created by Autoit in the current running script..

In your first post you didn't mention an external listview control generated by another application was what you were trying to set data in.

Maybe look at using UDF listview functions from a current Autoit beta to accomplish what your after.

And/Or

Have a look at ControlSetText() instead maybe

Cheers

Edit: If your not calling an external listview then NO you haven't provided enough of a script to locate your errors..

I was trying to set the data in my own listview control, which was $nListview. BTW: I tried _GUICtrlListViewCopyItems and it is TOTALLY useless. It eithers sucks like crap or I used it wrong (which I didn't because I copied exactly from the help file)

Anyways, I'll take a look at controlsettext() but if you have any ideas or suggestions on what it's not working get back to me. Thanks

FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

Hi,

Again, please post your script; you have a bug and it is impossible to know what you are doing without the script..

best, randall

Did you not see it in post #5? That right there is EVERYTHING that has to do with anything I'm talking about.

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

Did you not see it in post #5? That right there is EVERYTHING that has to do with anything I'm talking about.

Sorry but everything is not there , your expecting ppl to assume what you've written!

variables, arrays and win titles you've declared and/or know what they are and belong to, but we have to guess.. eg:

$nListview
Is this a listview item or the main listview control??

I can't see what the problem is with posting an actuall working example of your problem..

It can't be that hard to do..

That code in post #5 is gibberish to others as it is atm, no one else can run that code without first writing the rest of the code that your not submitting for some reason.

Good luck and cheers.

Link to comment
Share on other sites

Here's more of my code. Hope it is enough.

$nListview = GUICtrlCreateListView("Online|Buddy Name     ", 30, 85, 230, 200)

$var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
If WinExists("Window App", "" ) Then
                WinActivate("Window App", "")
                Send("{CTRLDOWN}{f}")
                Send("{CTRLUP}")
                $buddiesSearch = StringSplit($var, ",")
           ;Check if any words found
                If WinExists("Find", "") Then
                If IsArray($buddiesSearch) Then
                For $i = 1 To $buddiesSearch[0]
                    Send($buddiesSearch[$i] & ControlClick("Find", "", 258));Clicks the search button on the window
                    If WinActive("[CLASS:32770]", "") Then; If msgbox appears then...
                        GUICtrlSetData($nListview, "No")
                    Else
                        GUICtrlSetData($nListview, "Yes")
                    EndIf                   
            Next
        EndIf
    Else
        MsgBox(0, "", "Unable to search.")
    EndIf
            Else
                MsgBox(16, "Error", "Window App isn't even running!")
            EndIf

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

Looks to me I showed a lot already. Yes, my listview handle # is correct.

Hi,

That's a start, though you still have not shown what you have named each individual listview item; and there is your problem

As in previous posts,

do you have the ListView item handle number correct

listview handle # is correct.

You see, i asked about the "ListView item handle number ", but you are using the "listview handle # ", so can't use "$nListView" in that SetData func.

Best, randall

Link to comment
Share on other sites

Hi,

That's a start, though you still have not shown what you have named each individual listview item; and there is your problem

As in previous posts,

You see, i asked about the "ListView item handle number ", but you are using the "listview handle # ", so can't use "$nListView" in that SetData func.

Best, randall

$nListview = GUICtrlCreateListView("Online|Buddy Name     ", 30, 85, 230, 200)

$var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
If WinExists("Window App", "" ) Then
                WinActivate("Window App", "")
                Send("{CTRLDOWN}{f}")
                Send("{CTRLUP}")
                $buddiesSearch = StringSplit($var, ",")
              ;Check if any words found
                If WinExists("Find", "") Then
                If IsArray($buddiesSearch) Then
                For $i = 1 To $buddiesSearch[0]
                    Send($buddiesSearch[$i] & ControlClick("Find", "", 258));Clicks the search button on the window
                    If WinActive("[CLASS:32770]", "") Then; If msgbox appears then...
                        GUICtrlSetData($nListview, "No")
                    Else
                        GUICtrlSetData($nListview, "Yes")
                    EndIf                   
            Next
        EndIf
    Else
        MsgBox(0, "", "Unable to search.")
    EndIf
            Else
                MsgBox(16, "Error", "Window App isn't even running!")
            EndIf

Func myfunc()
$var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
    $arr = StringSplit($var, ",")
    For $val In $arr
        GUICtrlCreateListViewItem("|" & $val, $nListview)
    Next
EndFunc

I'm pretty sure what you're looking for is in myfunc(). Hope it's enough this time. :P

Edited by FireLord

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
Share on other sites

Hi,

maybe,

i can't test it, but to give you an idea;,....

; nListviewProb.au3
global $ar_ListViewItemHandle[1]
$nListview = GUICtrlCreateListView("Online|Buddy Name      ", 30, 85, 230, 200)

$var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
If WinExists("Window App", "" ) Then
                WinActivate("Window App", "")
                Send("{CTRLDOWN}{f}")
                Send("{CTRLUP}")
                $buddiesSearch = StringSplit($var, ",")
              ;Check if any words found
                If WinExists("Find", "") Then
                If IsArray($buddiesSearch) Then
                For $i = 1 To $buddiesSearch[0]
                    Send($buddiesSearch[$i] & ControlClick("Find", "", 258));Clicks the search button on the window
                    If WinActive("[CLASS:32770]", "") Then; If msgbox appears then...
                        GUICtrlSetData( $ar_ListViewItemHandle[$i], "No")
                    Else
                        GUICtrlSetData($ar_ListViewItemHandle[$i], "Yes")
                    EndIf                    
            Next
        EndIf
    Else
        MsgBox(0, "", "Unable to search.")
    EndIf
            Else
                MsgBox(16, "Error", "Window App isn't even running!")
            EndIf

Func myfunc()
$var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
    $arr = StringSplit($var, ",")
    redim $ar_ListViewItemHandle[UBound($arr)]
    for $val=1 to UBound($arr)-1
;~     For $val In $arr

        $ar_ListViewItemHandle[$val]=GUICtrlCreateListViewItem("|" & $val, $nListview)
;~         $ar_ListViewItemHandle[]=GUICtrlCreateListViewItem("|" & $val, $nListview)
    Next
EndFunc
best, randall

PS but where have you called "myfunc"?.....

Edited by randallc
Link to comment
Share on other sites

Hi,

maybe,

i can't test it, but to give you an idea;,....

; nListviewProb.au3
global $ar_ListViewItemHandle[1]
$nListview = GUICtrlCreateListView("Online|Buddy Name      ", 30, 85, 230, 200)

$var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
If WinExists("Window App", "" ) Then
                WinActivate("Window App", "")
                Send("{CTRLDOWN}{f}")
                Send("{CTRLUP}")
                $buddiesSearch = StringSplit($var, ",")
              ;Check if any words found
                If WinExists("Find", "") Then
                If IsArray($buddiesSearch) Then
                For $i = 1 To $buddiesSearch[0]
                    Send($buddiesSearch[$i] & ControlClick("Find", "", 258));Clicks the search button on the window
                    If WinActive("[CLASS:32770]", "") Then; If msgbox appears then...
                        GUICtrlSetData( $ar_ListViewItemHandle[$i], "No")
                    Else
                        GUICtrlSetData($ar_ListViewItemHandle[$i], "Yes")
                    EndIf                    
            Next
        EndIf
    Else
        MsgBox(0, "", "Unable to search.")
    EndIf
            Else
                MsgBox(16, "Error", "Window App isn't even running!")
            EndIf

Func myfunc()
$var = INIRead("C:\buddies.ini", "BuddyList", "Buddies", "Unable to read INI.")
    $arr = StringSplit($var, ",")
    redim $ar_ListViewItemHandle[UBound($arr)]
    for $val=1 to UBound($arr)-1
;~     For $val In $arr

        $ar_ListViewItemHandle[$val]=GUICtrlCreateListViewItem("|" & $val, $nListview)
;~         $ar_ListViewItemHandle[]=GUICtrlCreateListViewItem("|" & $val, $nListview)
    Next
EndFunc
best, randall

PS but where have you called "myfunc"?.....

I call it when I press the refresh button on my GUI. It's not shown in this code posting though.

[center]See the Helpfile[/center]

While Alive()
	 DrinkWine();
}
[center][/center]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...