Jump to content

multiple inputbox and list


Recommended Posts

Ok I have 4 or 5 Inputboxes and one list. the thing is that when i hit a button the text written in those inputboxes should be in the list and in the same row also i need the text in inputbox to disappear. I don't know how to do that.

Here is code I've done so far

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

#Region ### START Koda GUI section ### Form=c:\documents and settings\marko\desktop\koda_2007.06.09\forms\tata\forme\nabava.kxf
$Form1_2 = GUICreate("NURMO", 633, 464, 193, 115)
$Label1 = GUICtrlCreateLabel("NABAVA", 24, 16, 65, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 136, 56, 249, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("", 136, 88, 249, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Input3 = GUICtrlCreateInput("", 136, 120, 121, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Input4 = GUICtrlCreateInput("", 136, 152, 121, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Input5 = GUICtrlCreateInput("", 136, 184, 121, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Input6 = GUICtrlCreateInput("", 136, 216, 121, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Serijski broj:", 24, 56, 77, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Naziv:", 24, 88, 41, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Datum knjienja:", 24, 120, 101, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Količina:", 24, 152, 54, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Cijena:", 24, 184, 45, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label7 = GUICtrlCreateLabel("Svota:", 24, 216, 42, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label8 = GUICtrlCreateLabel("kn", 264, 192, 18, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label9 = GUICtrlCreateLabel("kn", 264, 224, 18, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Nova stavka", 528, 56, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Brii stavku", 528, 96, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("Uredi stavku", 528, 136, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$List1 = GUICtrlCreateList("", 24, 264, 593, 166)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button4 = GUICtrlCreateButton("Izlaz", 528, 176, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label10 = GUICtrlCreateLabel("komada", 264, 160, 54, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$MenuItem1 = GUICtrlCreateMenu("&Izbor")
$MenuItem2 = GUICtrlCreateMenuItem("Novi zapis", $MenuItem1)
$MenuItem6 = GUICtrlCreateMenuItem("Uredi stavku", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Spemi", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("Brii", $MenuItem1)
$MenuItem5 = GUICtrlCreateMenuItem("Izlaz", $MenuItem1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem5
            Exit
        Case $Button4
            Exit
        Case $Button1
            $input1 = GUICtrlRead($Input1)
            $input2 = GUICtrlRead($Input2)
            $input3 = GUICtrlRead($Input3)
            $input4 = GUICtrlRead($Input4)
            $input5 = GUICtrlRead($Input5)
            $input6 = GUICtrlRead($Input6)
            $temp = FileOpen("temp.txt",2)
            FileWrite($temp, $input1&" ")
            FileWrite($temp, $input2&" ")
            FileWrite($temp, $input3&" ")
            FileWrite($temp, $input4&" ")
            FileWrite($temp, $input5&" kn ")
            FileWrite($temp, $input6&" kn")
            _GUICtrlListAddItem($List1,$input1 & " | "& $input2 & " | "& $input3 & " | "& $input4 & " | "& $input5 & " | "& $input6)

    EndSwitch
WEnd

Thanks

Link to comment
Share on other sites

Ok I have 4 or 5 Inputboxes and one list. the thing is that when i hit a button the text written in those inputboxes should be in the list and in the same row also i need the text in inputbox to disappear. I don't know how to do that.

The "Nova Stavka" button works now:

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

$Form1_2 = GUICreate("NURMO", 633, 464, 193, 115)
$Label1 = GUICtrlCreateLabel("NABAVA", 24, 16, 65, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")

Global $InputIDs[6], $w = 249
For $n = 0 To 5
    $y = 56 + ($n * 32)
    If $n >= 2 Then $w = 121
    $InputIDs[$n] = GUICtrlCreateInput("", 136, $y, $w, 24)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Next

$Label2 = GUICtrlCreateLabel("Serijski broj:", 24, 56, 77, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Naziv:", 24, 88, 41, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Datum knjienja:", 24, 120, 101, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Kolicina:", 24, 152, 54, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Cijena:", 24, 184, 45, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label7 = GUICtrlCreateLabel("Svota:", 24, 216, 42, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label8 = GUICtrlCreateLabel("kn", 264, 192, 18, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label9 = GUICtrlCreateLabel("kn", 264, 224, 18, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Nova stavka", 528, 56, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Brii stavku", 528, 96, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("Uredi stavku", 528, 136, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$List1 = GUICtrlCreateList("", 24, 264, 593, 166)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button4 = GUICtrlCreateButton("Izlaz", 528, 176, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label10 = GUICtrlCreateLabel("komada", 264, 160, 54, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$MenuItem1 = GUICtrlCreateMenu("&Izbor")
$MenuItem2 = GUICtrlCreateMenuItem("Novi zapis", $MenuItem1)
$MenuItem6 = GUICtrlCreateMenuItem("Uredi stavku", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Spemi", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("Brii", $MenuItem1)
$MenuItem5 = GUICtrlCreateMenuItem("Izlaz", $MenuItem1)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem5
            Exit
        Case $Button4
            Exit
        Case $Button1
            ; $temp = FileOpen("temp.txt", 2)  <==== All file ops commented out for demo
            $NewListItem = ""
            For $n = 0 To 5
                $NewListItem &= GUICtrlRead($InputIDs[$n]) & " | "
                ; FileWrite($temp, $InputIDs[$n] & " ")
                ; If $n >= 4 Then FileWrite($temp, " kn ")
                GUICtrlSetData($InputIDs[$n], "")
            Next
            ; FileWrite($temp, @CRLF)
            ; FileClose($temp)
            $NewListItem = StringTrimRight($NewListItem, 3)
            _GUICtrlListAddItem($List1, $NewListItem)
    EndSwitch
WEnd

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks man I may have some more questions for you about this stuff in this topic during my development of this aplication.

EDIT: I have new question:

Datum is date in croatian.

I need that in the inputbox by the label datum should be written _NowDate().

Sorry I forgot to ask before.

Edited by searchresult
Link to comment
Share on other sites

Datum is date in croatian.

I need that in the inputbox by the label datum should be written _NowDate().

Looking at the code you had, and my modification to it, you can see how to create an inputbox and a label.

In my code you see GuiCtrlSetData() used to put data into the inputboxes.

That's all you need.

One of the big mistakes in your code was overwriting the control IDs.

When you create any control, like the inputboxes and buttons, the return is the control's ID.

That should be saved so it can be used later, and not overwritten.

In my code you see the control IDs for the input boxes kept in an array.

You want to use the control ID of the inputbox in the GuiCtrlSetData() function.

Another tip: you can nest function calls in AutoIt.

That means for example, that instead of two lines like this:

$NowDate = _NowDate()
GuiCtrlSetData($InputBox, $NowDate)oÝ÷ ØjvÞvÞz'zX§zØb³²jëh×6GuiCtrlSetData($InputBox, _NowDate())

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I ran into a new problem see there are two inputs after I write values into them I need to multiply them and write that result in a last one that i know(to write in the last one).

Was there a question in there? Let's see some code. Did you try something and it didn't work? Post the code and you'll get plenty of help.

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Was there a question in there? Let's see some code. Did you try something and it didn't work? Post the code and you'll get plenty of help.

:rolleyes:

Well I chose to continue with the listview instead with a list. So my problem is that i don't know how to fill each column with a different input. And also when it is written in those cells i need to multiply last two cells values and write that value in the last one. here is my code:

#include <GUIConstants.au3>
#include <Date.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\marko\desktop\koda_2007.06.09\forms\tata\novo\form1.kxf
$Form1 = GUICreate("NURMO", 652, 477, 193, 115)
$ListView1 = GUICtrlCreateListView("Serijski broj|Naziv proizvoda|Datum knjienja|Količina|Cijena|Svota", 8, 216, 634, 182, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, 0x101E, 0, 120)
GUICtrlSendMsg(-1, 0x101E, 1, 120)
GUICtrlSendMsg(-1, 0x101E, 2, 120)
GUICtrlSendMsg(-1, 0x101E, 3, 100)
GUICtrlSendMsg(-1, 0x101E, 4, 80)
GUICtrlSendMsg(-1, 0x101E, 5, 83)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

Global $InputIDs[5], $w = 249
For $n = 0 To 4
    $y = 34 + ($n * 34)
    If $n >= 2 Then $w = 121
    $InputIDs[$n] = GUICtrlCreateInput("", 144, $y, $w, 24)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    If $n = 2 Then GUICtrlSetData($InputIDs[$n], _NowDate())
Next

$Label1 = GUICtrlCreateLabel("Serijski broj:", 16, 40, 91, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Naziv proizvoda:", 16, 72, 120, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Datum knjienja:", 16, 106, 117, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Količina:", 16, 142, 63, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Cijena:", 16, 176, 52, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("kn", 272, 179, 20, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label7 = GUICtrlCreateLabel("kom", 272, 146, 33, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Nova stavka", 552, 40, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Brii stavku", 552, 88, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("Izlaz", 552, 408, 91, 33, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label8 = GUICtrlCreateLabel("NURMO - NABAVA", 16, 8, 134, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x6D87BE)
$MenuItem1 = GUICtrlCreateMenu("&Izbor")
$MenuItem2 = GUICtrlCreateMenuItem("Nova stavka", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Spremi", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("Brii", $MenuItem1)
$MenuItem5 = GUICtrlCreateMenuItem("Izlaz", $MenuItem1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button3, $MenuItem5
    Exit
Case $Button1, $MenuItem2
            $NewListItem = ""
            For $n = 0 To 4
                $NewListViewItem &= GUICtrlRead($InputIDs[$n])
                GUICtrlSetData($InputIDs[$n], "")
                    If $n = 2 Then GUICtrlSetData($InputIDs[$n],_NowDate())
            Next

            $NewListViewItem = StringTrimRight($NewListItem, 3)
           GUICtrlCreateListViewItem($NewListViewItem, $ListView1)


EndSwitch
WEnd

thing that happens all the time is that it is always writing it in the first cell instead each one in the separate cell.

just don't have any idea any more i tried all that is written in the help file but nothing that i could do about.

thanks

Link to comment
Share on other sites

Well I chose to continue with the listview instead with a list. So my problem is that i don't know how to fill each column with a different input. And also when it is written in those cells i need to multiply last two cells values and write that value in the last one. here is my code:

thing that happens all the time is that it is always writing it in the first cell instead each one in the separate cell.

just don't have any idea any more i tried all that is written in the help file but nothing that i could do about.

thanks

You only need to change one line:

; $NewListViewItem &= GUICtrlRead($InputIDs[$n])
                $NewListViewItem &= GUICtrlRead($InputIDs[$n]) & " | "

The columns in a new list view item are delimited by the pipe symbol "|".

The help file for GuiCtrlCreateListViewItem() surprisingly does NOT tell you this, but the example shown there clearly demonstrates it.

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

You only need to change one line:

; $NewListViewItem &= GUICtrlRead($InputIDs[$n])
                $NewListViewItem &= GUICtrlRead($InputIDs[$n]) & " | "

The columns in a new list view item are delimited by the pipe symbol "|".

The help file for GuiCtrlCreateListViewItem() surprisingly does NOT tell you this, but the example shown there clearly demonstrates it.

:rolleyes:

Have you tried it cause i have. When you input data once it is ok but the next time it isn't ok.

Also i have asked how to multiply the last two cells with data and input that result in the last cell?

Link to comment
Share on other sites

Have you tried it cause i have. When you input data once it is ok but the next time it isn't ok.

Also i have asked how to multiply the last two cells with data and input that result in the last cell?

You gotta start paying closer attention:

Case $Button1, $MenuItem2
            $NewListViewItem = ""
            For $n = 0 To 4
                $NewListViewItem &= GUICtrlRead($InputIDs[$n]) & " | "
                GUICtrlSetData($InputIDs[$n], "")
                    If $n = 2 Then GUICtrlSetData($InputIDs[$n],_NowDate())
            Next

            $NewListViewItem = StringTrimRight($NewListViewItem, 3)
           GUICtrlCreateListViewItem($NewListViewItem, $ListView1)

Not the corrected miss-spellings of the variable name $NewListViewItem... :rolleyes:

As for the other part, figure it out. You know how to read the first two controls now, and you know how to set data on the third control. Look in the help file under 'Operators' for multiplication operator and code it up.

Time to take some baby steps on your own.

:rambo:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...