Jump to content

select in GUICtrlCreateListView put into GUICtrlCreateInput whit array


Erik.
 Share

Recommended Posts

Hi,

I have tried it yesterday the hole day but it seems not working for mee.

What i want to try:

You a GUICtrlCreateListView and 7 GUICtrlCreateInput in a gui

Now does the GUICtrlCreateListView 7 arrays

card|first|last|street|city|phonenumber|postalzip

Now am i tring to make something, you can select someone in the GUICtrlCreateListView and all his data will be put into the 7 GUICtrlCreateInput and each array into one GUICtrlCreateInput like this:

1|erik|jason|kerstraat|ergens|1234567890|1245sc

in the GUICtrlCreateInput:

GUICtrlCreateInput 1: 1

GUICtrlCreateInput 2: Erik

GUICtrlCreateInput 3: jason

GUICtrlCreateInput:4: kerkstraat

GUICtrlCreateInput 5: ergens

GUICtrlCreateInput 6: 1234567890

GUICtrlCreateInput 7: 1245sc

And when you select someone else that his data will be put into the 7 GUICtrlCreateInput

why i want this:

it is easyer for people to edit someone when his data is incorect you don't need to full all his data again but edit the data that was wrong...

Could someone help me whit it?

Gr Erik

I little problem, hard to find and fix

Link to comment
Share on other sites

Provide the best code sample you have until now. If you do, and none else helps you out, I will try to do so tomorrow. Got to go now..:P

In the meantime you should study the helpfile samples

#include <GUIConstants.au3>

GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF)  ; will change background color

$listview = GuiCtrlCreateListView ("col1  |col2|col3  ",10,10,200,150);,$LVS_SORTDESCENDING)
$button = GuiCtrlCreateButton ("Value?",75,170,70,20)
$item1=GuiCtrlCreateListViewItem("item2|col22|col23",$listview)
$item2=GuiCtrlCreateListViewItem("............item1|col12|col13",$listview)
$item3=GuiCtrlCreateListViewItem("item3|col32|col33",$listview)
$input1=GuiCtrlCreateInput("",20,200, 150)
GuiCtrlSetState(-1,$GUI_DROPACCEPTED)   ; to allow drag and dropping
GuiSetState()
GUICtrlSetData($item2,"|ITEM1")
GUICtrlSetData($item3,"||COL33")
GUICtrlDelete($item1)

Do
  $msg = GuiGetMsg ()
     
   Select
      Case $msg = $button
         MsgBox(0,"listview item",GUICtrlRead(GUICtrlRead($listview)),2)
      Case $msg = $listview
         MsgBox(0,"listview", "clicked="& GuiCtrlGetState($listview),2)
   EndSelect
Until $msg = $GUI_EVENT_CLOSE
Link to comment
Share on other sites

Hi,

I don't have a code beacuase i was looking into the help file and eddited somethings to look if it works..

This is what i have..

#include <GuiConstants.au3>

#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)

Dim $listview, $Btn_Exit, $msg, $Status, $pos

GUICreate("ListView Get Current Selection", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)

GUICtrlCreateListViewItem("line1|data1|more1", $listview)

$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)

$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit

ExitLoop

Case $msg = $GUI_EVENT_PRIMARYDOWN

GUICtrlSetData($Status, _GUICtrlListViewGetItemText ($listview))

EndSelect

WEnd

Exit

i was trying to get one data into the label

But i get all data of the GUICtrlCreateListView but i want one array for example i only want to see the first colum info.

Edited by Erik.

I little problem, hard to find and fix

Link to comment
Share on other sites

Hi,

i have some damm error.

this is what i have:

#include <GuiConstants.au3>

#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)

Dim $listview, $Btn_Get, $Btn_GetSelected, $Btn_Exit, $msg, $Status, $a_Item, $i

GUICreate("ListView Get Item Text Array", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)

GUICtrlCreateListViewItem("line1|data1|more1", $listview)

GUICtrlCreateListViewItem("line2|data2|more2", $listview)

GUICtrlCreateListViewItem("line3|data3|more3", $listview)

GUICtrlCreateListViewItem("line4|data4|more4", $listview)

GUICtrlCreateListViewItem("line5|data5|more5", $listview)

$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)

$Status = GUICtrlCreateInput("", 50, 200, 40, 20)

$input = GUICtrlCreateInput("", 50, 230, 40, 20)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit

ExitLoop

Case $msg = $GUI_EVENT_PRIMARYDOWN

GUICtrlSetData($Status, "")

$a_Item = _GUICtrlListViewGetItemTextArray ($listview)

If (Not IsArray($a_Item)) Then

GUICtrlSetData($Status, "")

if (Not IsArray($a_Item)) Then

GUICtrlSetData($input, "")

Else

GUICtrlSetData($Status,$a_Item[1])

GUICtrlSetData($input,$a_Item[2])

EndIf

EndIf

EndSelect

WEnd

Exit

it does not work why?

EDIT:

what does this mean:$GUI_EVENT_PRIMARYDOWN?

Does it mean that it will look always you do not need to press a button?

When i put it into my script does it run always whit other cases or only when nothing is running?

Edited by Erik.

I little problem, hard to find and fix

Link to comment
Share on other sites

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

Opt('MustDeclareVars', 1)
Dim $listview, $Btn_Get, $Btn_GetSelected, $Btn_Exit, $msg, $Status, $a_Item, $i, $input
GUICreate("ListView Get Item Text Array", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateInput("", 50, 200, 40, 20)
$input = GUICtrlCreateInput("", 50, 230, 40, 20)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            $a_Item = _GUICtrlListViewGetItemTextArray($listview)
            If IsArray($a_Item) Then
                GUICtrlSetData($Status, "")
                GUICtrlSetData($Status, $a_Item[1])
                GUICtrlSetData($input, $a_Item[2])
            Else
                GUICtrlSetData($input, "")
            EndIf
    EndSelect
WEnd
Exit

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

; ----------------------------------------------------------------------------
; Erik.au3
; ----------------------------------------------------------------------------

; ------------------- Included Files ----------------------------------
#include <GuiConstants.au3>
#include <Misc.au3>
#include <File.au3>
#Include <GuiListView.au3>
#include <GuiList.au3>
#include <Array.au3>
#Include <GuiStatusBar.au3>
#include <Constants.au3>
#include <String.au3>
#NoTrayIcon

; ------------------- Options ----------------------------------
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1
;ListView Events
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)

; ------------------- Variables and globals ----------------------------------
Dim $input[8]
Dim $data[8]
Dim $label[8]
$data[0] = 'ID'
$data[1] = 'First name'
$data[2] = 'Last name'
$data[3] = 'Street'
$data[4] = 'City'
$data[5] = 'Phone number'
$data[6] = 'ZIP code'
Global $size = 100
Global $space = 50
Global $datasize = 30
Global Const $MIM_APPLYTOSUBMENUS   = 0x80000000
Global Const $MIM_BACKGROUND        = 0x00000002
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

; ------------------- Check if folders & files excist----------------------------------
Global $win_1 = GUICreate('Erik.au3', 800, 450)     

; ------------------- GUI ----------------------------------
$listview = GUICtrlCreateListView ('ID|First name|Last name|Street|City|Phone number|ZIP code',140,20,600,350,-1,BitOR($LVS_EX_REGIONAL, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
For $i = 0 To 6
    _GUICtrlListViewSetColumnWidth($listview,$i,$size)
Next
$B_DESCENDING = _GUICtrlListViewGetSubItemsCount($listview)

For $j = 1 To 7
    $input[$j] = GUICtrlCreateInput('',10,($j*$space),100,25)
Next

For $k = 0 To 6
    $label[$k] = GUICtrlCreateLabel($data[$k],10,30+($k*50),100,15)
Next

;-------------------All your Listview Data------------
$item = GUICtrlCreateListViewItem("1|John|Williams|Rue de la Blaat|Amsterdam|020-3333333|7262 AC",$listview)
;-------------Standard...-----
GuiSetState()
    
While 1
$msg = GuiGetMsg()

Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop        
        Case $listview          
            _GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))      
EndSwitch   
WEnd
GUIDelete($win_1)
Exit

; ------------------- Functions ----------------------------------
Func ListView_Click()
  ;If $DebugIt Then ConsoleWrite (_DebugHeader ("$NM_CLICK"))
EndFunc;==>ListView_Click

Func ListView_DoubleClick()
    $a_Item = _GUICtrlListViewGetItemTextArray ($listview)  
    For $m = 1 To $a_Item[0]
        GuiCtrlSetData($input[$m],$a_Item[$m])      
    Next
EndFunc;==>ListView_DoubleClick

; WM_NOTIFY event handler
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select  
    Case $wParam = $ListView
        Select
            Case $event = $NM_CLICK
                ListView_Click ()
            Case $event = $NM_DBLCLK
                ListView_DoubleClick ()
            EndSelect   
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc;==>WM_Notify_Events

Try it out and one advice, most things are in the helpfile...

Edited by Noobster24
Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.
Link to comment
Share on other sites

Hi,

This is what i have made but it only does not seems to work how i want to..

I must edit the value of a key but it now delete the key and put a new one whit the same data as what it was thats not what i want..

You have 8 GUICtrlCreateInput and when you select someone in the listview it put the data in the GUICtrlCreateInput then you can edit them and press save then it must look for the key and overwrite it but does not work..

Does some one why?

My code:

#Include <GUIConstants.au3>
#Include <GuiListView.au3>
#Include <File.au3>
#include <Date.au3>
#include <Array.au3>
#include <Date.au3>
#NoTrayIcon


Global $i = 1,$a = 1, $null, $er = 0, $ers = 0, $firstperson = 0, $error = 0, $f = 1
$dir = @ProgramFilesDir & "\I Meet"
$config = $dir & "\config.cfg"
$members = $dir & "\members.dbs"
$backup = $dir & "\backup"
$banfile = $dir & "\banlist.ban"
$extra = $dir & "\extra.xtr"


Dim $listview, $Btn_Get, $Btn_GetSelected, $Btn_Exit, $msg, $Status, $a_Item, $i, $input
GUICreate("ListView Get Item Text Array", 800, 500)

$listview = GUICtrlCreateListView("Pasnummer|Voornaam|Achternaam|Woonplaats|Adres|Postcode|Leeftijd|Telefoon nummer|Tijd|Commentaar", 0, 0, 700, 369)
$Btn_Exit = GUICtrlCreateButton("Exit", 700, 450, 70, 20)
$opslaan = GUICtrlCreateButton("Oplsaan", 30, 450, 70, 20)
$input1 = GUICtrlCreateInput("", 2, 400, 50, 20,$ES_READONLY)
$input2 = GUICtrlCreateInput("", 62, 400, 55, 20)
$input3 = GUICtrlCreateInput("", 127, 400, 100, 20)
$input4 = GUICtrlCreateInput("", 237, 400, 100, 20)
$input5 = GUICtrlCreateInput("", 347, 400, 140, 20)
$input6 = GUICtrlCreateInput("", 497, 400, 50, 20)
$input7 = GUICtrlCreateInput("", 557, 400, 60, 20)
$input8 = GUICtrlCreateInput("", 627, 400, 75, 20)
$label = GUICtrlCreateLabel("loading data base please stand by", 0, 480, 800, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$path = _PathSplit(FileOpenDialog("Selecteer datum voor open",$dir,".ini's (*.ini;*members.dbs)"),$null,$null,$null,$null)
GUISetState()
If $path[3] & $path[4] = "members.dbs" Then
        For $t = 1 to IniRead($members,"Totaal","1","")
            GUICtrlCreateListViewItem(IniRead($members,"Members",$t,""),$listview)
        Next
    Else
        For $t = 1 to IniRead($config,"Data",$path[3] & $path[4],"")
            GUICtrlCreateListViewItem(IniRead($dir & "\" & $path[3] & $path[4],"Info_Vandaag",$t,""),$ListView)
        Next
    EndIf
    GUICtrlSetData($label,"ready")
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            $a_Item = _GUICtrlListViewGetItemTextArray($listview)
            If IsArray($a_Item) Then
                GUICtrlSetData($label,"selected " & $a_Item[2]  & " " & $a_Item[3])
                GUICtrlSetData($Status, "")
                GUICtrlSetData($input1,$a_Item[1])
                GUICtrlSetData($input2,$a_Item[2])
                GUICtrlSetData($input3,$a_Item[3])
                GUICtrlSetData($input4,$a_Item[4])
                GUICtrlSetData($input5,$a_Item[5])
                GUICtrlSetData($input6,$a_Item[6])
                GUICtrlSetData($input7,$a_Item[7])
                GUICtrlSetData($input8,$a_Item[8])
            Else
                GUICtrlSetData($label,"no one selected")
                GUICtrlSetData($input1, "")
                GUICtrlSetData($input2, "")
                GUICtrlSetData($input3, "")
                GUICtrlSetData($input4, "")
                GUICtrlSetData($input5, "")
                GUICtrlSetData($input6, "")
                GUICtrlSetData($input7, "")
                GUICtrlSetData($input8, "")
            EndIf
        Case $msg = $opslaan
            $ers = 0
             $return1 = _GUICtrlListViewGetItemText($ListView)   
             $return = StringSplit($return1,"|")
                If $return[1] = "" Then
                    MsgBox(0,"Error","no one selected")
                    ContinueLoop
                ElseIf $return[1] <> "" Then
                    MsgBox(0,"test",$return[1])
                    $get1 = _GUICtrlListViewGetItemText($ListView)   
                    $weetuzekerwijzigen = msgbox(4,"Sure?","Are you sure that:" & @CRLF & $get1 & "should be changed?")
                    If $weetuzekerwijzigen = 6 Then
                        $var = IniReadSection($members,"Members")
                        GUICtrlSetData($label,"Bezig met zoeken...")
                        If @error Then
                            MsgBox(4096, "Error", "Database could not been found")
                        EndIf
                        $Found = 0
                        For $i = 1 To $var[0][0]
                            $IniKeys = StringSplit($var[$i][1], "|")
                            If $return[1] = $IniKeys[1] Then
                                $Found = 1
                                GUICtrlSetData($label,"Person found, changing data")
                                msgbox(0,"test1",$var[$i][0])
                                Inidelete($members,"Members",$var[$i][0])
                                Sleep(500)
                                Iniwrite($members,"Members",$var[$i][0],GUICtrlRead($input1) & "|" & GUICtrlRead($input2) & "|" &  _ 
                                    GUICtrlRead($input3) & "|" & GUICtrlRead($input4) & "|" & GUICtrlRead($input5) & "|" & _ 
                                    GUICtrlRead($input6) & "|" & GUICtrlRead($input7) & "|" & GUICtrlRead($input8))
                                GUICtrlSetData($label,"Data has changed")
                                exitLoop
                            Else 
                            EndIf
                        Next
                        If $Found = 0 Then
                            Msgbox(0,"Person not found","Person not found")
                            ContinueLoop
                        EndIf
                    Else
                        ContinueLoop
                    EndIf
                EndIf                   
    EndSelect
WEnd
Exit
Edited by Erik.

I little problem, hard to find and fix

Link to comment
Share on other sites

Looks like you have made good progress. But, you have to many dependencies in you code for effective use in a dialog like this forum is. Try to break it down to the simplest sample you can think of and explain what your problems are out of that.

As I understand it you have problems with updating ListViewItems at the moment. The help file sample for GUICtrlCreateListViewItem is reasonably small, so lets work from that.

And this is my result.

#include <GUIConstants.au3>
#Include <GuiListView.au3>

GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF)  ; will change background color

$listview = GuiCtrlCreateListView ("col1  |col2|col3  ",10,10,200,150);,$LVS_SORTDESCENDING)
$button = GuiCtrlCreateButton ("Value?",75,170,70,20)
$update = GuiCtrlCreateButton("Update", 75 + 70 + 5, 170, 70, 20)
$item1=GuiCtrlCreateListViewItem("item2|col22|col23",$listview)
$item2=GuiCtrlCreateListViewItem("............item1|col12|col13",$listview)
$item3=GuiCtrlCreateListViewItem("item3|col32|col33",$listview)
$input1=GuiCtrlCreateInput("test1|test2|test3",20,200, 150)
GuiCtrlSetState(-1,$GUI_DROPACCEPTED)   ; to allow drag and dropping
GuiSetState()
GUICtrlSetData($item2,"|ITEM1")
GUICtrlSetData($item3,"||COL33")
GUICtrlDelete($item1)

Do
  $msg = GuiGetMsg ()
     
   Select
      Case $msg = $button
         MsgBox(0,"listview item",GUICtrlRead(GUICtrlRead($listview)),2)
      Case $msg = $listview
         MsgBox(0,"listview", "clicked="& GuiCtrlGetState($listview),2)
      Case $msg = $update
         $current = _GUICtrlListViewGetCurSel($listview)
         $data = GUICtrlRead($input1)
         ConsoleWrite("$current:=" & $current & ", $data:=" & $data & @LF)
         ;GuiCtrlSetData($listview, $data)
         $foo = StringSplit($data, "|")
         For $i = 1 to $foo[0]
            _GUICtrlListViewSetItemText($listview, $current, $i - 1, $foo[$i])
         Next 
   EndSelect
Until $msg = $GUI_EVENT_CLOSE

PS: Use the autoit tags to ease code reading..:P

Link to comment
Share on other sites

Hi,

I Know what my problem was..

You see at my script by the case i have $GUI_EVENT_PRIMARYDOWN that means it always run that case when nothing else is pressed.

When you select someone it copy's it into the inputboxes.

You can edit it but the problem was that when you have editted the program still was refressing because that case was rinning all the time so you can do what you want but you can not edit it..

So i made a button of it and now it works..

If you want to see what i mean copy my script and then put data into the listview

Select that person or thing and then edit it

Press again into the input what you have editted and you will see that the text is the same as the listview you selected..

i hope you understand what the problem was..

Thanks for you help

Gr Erik

EDIT:

When i have in the listview not all data set some collums are empty how to made when you press a raow and press a buttun you can add not to the listview and file but not need to delete the listviewitem or something like that?

Edited by Erik.

I little problem, hard to find and fix

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...