Jump to content

question about making a select/list type box

Recommended Posts


i have some code, that will enter data into a listbox, every time you click a button.

also, each time you click the button, i add a variable to itself + 1.

so you click the button once.... the list would look like this

hi, i have been clicked once

then the variable would have the value 1

$var = $var + 1

this variable keeps track of what line you entered any particular data on.

so if the list looked like this...

hi, i have been clicked once
hi, i have been clicked twice
hi, i have been clicked thrice

$var would = 3

i want the option of making it so that when i click another button, i can CHOOSE from a box that pops up... another list containing the variable increments,

then i can select one of the variables.... with some kind of checkbox.. would be best.

something that looks like this for a list.....

number 1:
number 2:
number 3:

with a checkbox next to each one.

i want to make it so when you click this button, it will ask what number would you like?

then i choose the number..

then i do a bunch of other crazy stuff with that user input i received.

so how would i make a list of checkboxes like this?

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

im not sure how to put it together...

lets say $var = 23

i would need to create the box when the user clicked a button,

and the list would have checkboxes next to each item....

( number 1: through number 23: )

then after checking the one/ones that they want, ( i want to be able to check multiple selections at the same time, and have a "select all" button) you hit another button, and it would say something like...

do you really want to select 1: 3: 14: 19: and 22: ???

with an ok and cancel button.

then of course i would need to get rid of the box somehow, when they are finished.

and i looked through the help file, but the examples i see in there really arent enough for me, as they are general and not specific to what i need, and i still dont really understand the entire concept involved.

and i guess that im asking for someone to show me an example of some code, pretty much i would like a simple gui with one button, you press it, and it makes a list with 50 checkboxes and each checkbox would say number 1: through number 50:

then you can select, any by hand, or all with another checkbox.

and after you click "ok" on the "ok" button (should be an "ok" and "cancel" button)

then it will show a messagebox with the selections you selected.

i hope this isnt asking too much, i would learn from this, i just cant figure out exactly how to do this on my own.

and i am willing to integrate the code into my script myself, but i just want a simple example of a list of checkboxes that i can get user input from.

or.. maybe im begging.

one or the other.

but please!!!!!!!!


Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Look in the help file at _GUICtrlListViewGetItemText(), _GUICtrlListViewGetCheckedState(), _GUICtrlListViewSetCheckState(), _GUICtrlListViewGetSelectedIndices, _GUICtrlListViewGetSelectedCount and a For...Next loop with GUICtrlCreateListViewItem()

Something like...

For $I = 1 To 50
   GUICtrlCreateListViewItem($I, $listview)

For $I = 0 to _GUICtrlListViewGetSelectedCount
   $Split = StringSplit(_GUICtrlListViewGetSelectedIndices, "|")
   $Text = _GUICtrlListViewGetItemText($listview, $Split)
   MsgBox(0,"Result", $Text)

Just to get you started. Keep in mind the 2nd For...Next loop will only work when is more then 1 item selected because it uses StringSplit() to split the selected index's.

Edited by Burrup


Link to comment
Share on other sites

thanks for getting me started!

heres what i have created. (beta)

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)
Dim $listview, $Btn_SetAll, $Btn_check, $msg, $ret, $xx
GUICreate("testing", 392, 322)

$listview = GUICtrlCreateListView("test", 40, 30, 310, 149, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES ,  $LVS_EX_REGIONAL))

For $I = 1 To 50
   GUICtrlCreateListViewItem("item " & $I & ":",$listview)

_GUICtrlListViewSetColumnWidth ($listview, 0, 100)
$Btn_SetAll = GUICtrlCreateButton("Set All", 150, 230, 90, 25)
$Btn_check = GUICtrlCreateButton("check", 300, 260, 70, 30)
Local $check = 1
Local $checkall = 1
While 1
    $msg = GUIGetMsg()
    Case $msg = $Btn_check
                     For $x = 1 to 50
         $xx = $x - 1
         Local $is_Checked = _GUICtrlListViewGetCheckedState ($listview,$xx)
         If ($is_Checked <> $LV_ERR) Then
            If ($is_Checked) Then
              msgbox(0,"test", "Item " & $x & " is Checked")
              msgbox(0,"test", "Item " & $x & " is not Checked")

        Case $msg = $Btn_SetAll
            Local $ret = _GUICtrlListViewSetCheckState($listview, -1, $checkall)
            $checkall = Not $checkall
            If ($ret == $LV_ERR) Then
                MsgBox(0, "Error", "Error setting Check state")

now, what i would like to do is something like this

GUICtrlCreateListViewItem("item " & $I & @crlf & "next line",$listview)

i tried adding a pipe, and that didnt work either.

i want to add 2 lines of text vertically... for each item. is this possible?


item 1: this and        
item 2: is this

it said in the help file also, that with listview the height must be set to 0

so im thinking.. no

but still have to ask...

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

I'm pretty sure a List View Item can only be one line wide. Can't you create the first item, then create and empty line, then create the second, that would give the impression of what you want. Ofcourse if you selected/click on one of the lines the other would not be selected and the user would now that its just an empty line. Perhaps you might be able to over come that by using _GUICtrlListViewGetSelectedIndices() and _GUICtrlListViewSetItemSelState().


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

  • Recently Browsing   0 members

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