Listview add remove

Get help with using AutoHotkey and its commands and hotkeys
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Listview add remove

18 Dec 2017, 05:43

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Hello.

When I click on the add button,

I want to add the data in the name, surname and birth date boxes to the ListView.

  I want to delete it when I click on the select and remove button from ListView.

also: 3 columns in the ListView object. the titles of the columns will be the names of the "edit" boxes.
Thank you.
User avatar
divanebaba
Posts: 604
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Listview add remove

18 Dec 2017, 06:31

Hi.
Try this:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

18 Dec 2017, 06:53

Adamsın ! :)
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

18 Dec 2017, 07:06

ramazan brother will have another responsibility.

If I double click on any of the records you added to ListView,

Give your name, surname, date of birth with MsgBox respectively


ramazan abi bir sorum daha olacak.

listview'e eklediğin kayıtlardan herhangibirinin üzerine çift tıkladığımda,

adı, soyadı, doğum tarihini sırasıyla msgbox ile uyarı versin
User avatar
divanebaba
Posts: 604
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Listview add remove

18 Dec 2017, 07:08

Hi chngrcn,

I made a little mistake.
Using LV_InsertCol(...) is for modifiying ListViews.
You can even use directly

Code: [Select all] [Download] GeSHi © Codebox Plus

Gui, Add, ListView, x152 y20 w480 h290  LV0x1, Name|Surname|Birth Date
without LV_InsertCol(...).

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

18 Dec 2017, 07:16

also how can I keep records in memory. I do not want my records to be deleted every time I restart the script. How do I create a database?
User avatar
divanebaba
Posts: 604
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Listview add remove

18 Dec 2017, 07:19

Hallo chngrcn,

you endanger my anonymity. Please don't use my real name :crazy: :D :D

For your case, you have to add a gLabel into your ListView and a new label. Look code below:

Code: [Select all] [Download] GeSHi © Codebox Plus

Gui, Add, ListView, x152 y20 w480 h290  LV0x1 gSelection, Name|Surname|Birth Date
....
Selection:
msgbox % Name " - " Surname " - " Birth
return

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

18 Dec 2017, 07:27

also how can I keep records in memory. I do not want my records to be deleted every time I restart the script. How do I create a database?
User avatar
divanebaba
Posts: 604
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Listview add remove

18 Dec 2017, 07:56

chngrcn wrote:... how can I keep records in memory ... How do I create a database?

For this case, you have to store the content of the ListView into a variable, stored onto Harddrive.
By starting your script, you have to readout the stored variable and to insert into your ListView.
Look code below:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

By closing the gui, the content is stored into a text-file in scipt directory.

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

18 Dec 2017, 16:31

divanebaba wrote:SelectionLV:
if (LV_GetNext() < 1 || LV_GetNext() > LV_GetCount())
return
msgbox % Name " - " Surname " - " Birth
return



When I double click on Listview object, MsgBox is empty? Where does the code come from?
User avatar
divanebaba
Posts: 604
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Listview add remove

18 Dec 2017, 17:04

Hallo chngrcn.
I'm sorry, I forgot a bit of code. Please modify like below:

Code: [Select all] [Download] GeSHi © Codebox Plus

SelectionLV:
SelItem := LV_GetNext() ; get the number of the activated row
loop 3
Var%A_Index% = ; clearing the Variables to prevent wrong content while clicking not complete filled rows
LV_GetText(Var1, SelItem, 1) ; first column
LV_GetText(Var2, SelItem, 2) ; second column
LV_GetText(Var3, SelItem, 3) ; third column
if (SelItem < 1 || SelItem > LV_GetCount()) ; since we have stored LV_GetNext() into SelItem, we can use the variable instead of the function.
return
msgbox % Var1 " - " Var2 " - " Var2
return
The fault was forgetting the three lines with LV_GetText(...).
Replacing LV_GetNext() inside the if-statement is only for (maybe) more performance. I think storing and invoking this value had to be faster than invoking LV_GetNext().

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

19 Dec 2017, 01:36

Thank you. there will be another responsibility.
add another button, and when this button is pressed, delete the data in the "edit" boxes and move the cursor to the first box.

with code?

I also want the cursor to be in the first "edit" box when the script starts.
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

19 Dec 2017, 04:24

Code: [Select all] [Download] GeSHi © Codebox Plus

Clear:

for i, c in ["Name", "Surname", "Birth"] { ; Clear these edit boxes
%c% := ""
GuiControl,, %c%, % %c%
}
GuiControl, Focus, Name
return


Thank you. I'm find it.
User avatar
divanebaba
Posts: 604
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Listview add remove

19 Dec 2017, 10:29

Hallo chngrcn.

To put new content into the controls, you have to use GuiControl.
Look into help file to learn some options round about this command.
For your issue, modify your label, called clear: as described below:

Code: [Select all] [Download] GeSHi © Codebox Plus

Clear:
GuiContol,, Name
GuiContol,, Surname
GuiContol,, Birth
GuiControl, Focus, Name
return
You can make it complicated, by using loops or simple like described.

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

20 Dec 2017, 04:25

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus




code (tab1) and tab2 (tab2) are added.
I want shudder;

On the tab1 tab, create the "content1.txt" database for the operations that I have done on that tab.

On the tab2 tab, create the "content2.txt" database that contains the actions that I made on that tab.

when I toggle between tabs, I get a list of the tabs in that list.
User avatar
divanebaba
Posts: 604
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Listview add remove

20 Dec 2017, 06:55

Hallo chngrcn
I found a good template here.

EDIT: I changed the GuiClose label. Before it was buggy.
Last edited by divanebaba on 20 Dec 2017, 07:40, edited 1 time in total.

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

20 Dec 2017, 07:35

Thank you very much. divanebaba
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

20 Dec 2017, 09:30

there is a shortage in the "guiclose" section of the encoding.

After running the script after logging on and off on both tabs, it creates "content1" and "content2" files. So far, no problem. If we turn off the scipti and turn it back on again without entering any data, we are changing the names of the "content1" and "content2" files and reloading the existing "content1" and "content2" files.

for turkish

kodlamanın "guiclose" bölümünde bir eksiklik var.

script çalıştırtan sonra her iki sekme'de kayıt yapıp kapattıktan sonra, "content1" ve "content2" dosyalarını oluşturuyor. buraya kadar bir sorun yok. scipti kapatıp yeniden açtığımızda herhangi bir veri girişi yapmadan tekrar kapattığımızda, " "content1" ve "content2" dosyalarının adlarını değiştirip yedekliyor. mevcut "content1" ve "content2" dosyalarını yutuyor. bu sorunu nasıl halledebiliriz ?
User avatar
divanebaba
Posts: 604
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Listview add remove

20 Dec 2017, 09:47

Hallo chngrcn
my turkish is like my english, badly worse.
I've corrigated the code, because storing the contents was faulty. I think you have tried the faulty version.
If there are still any faults, tell me.

Best regards from Germany.

[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.
chngrcn
Posts: 82
Joined: 29 Feb 2016, 08:55

Re: Listview add remove

21 Dec 2017, 01:25

Good Morning divanebaba.

There was a backup problem. thank you.
MsJBOX gives warning when we click on empty lines in Listview. I want you to give a warning when we click on only the filled lines. terminate the loop when you click on empty lines.

also, do we have a chance to resize the listview columns in the existing code?

Return to “Ask For Help”

Who is online

Users browsing this forum: brutus_skywalker, VISHALVODRO and 37 guests