addgadgetitem

Just starting out? Need help? Post your questions and find answers here.
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

addgadgetitem

Post by t57042 »

Code: Select all

;test
 
Dim ar$(10) 
Dim fieldnm$(20)
Read.s tbl$   ; tablename
Read atfields  ; nr of fields
For i=1 To atfields
  Read.s fieldnm$(i)  ; name of fields
Next

ar$(1)="A\Fido\\Orcheta\s\644160698\fido.es@seznam.cz\bouw\\"
ar$(2)="A\Pedro - water\\Finestrat\s\\\water\65 Euro / camion\"
ar$(3)="D\Parking Ascars\\Alicante\s\965685200 / 616040832\parkingascars@msn.com\parking\contr 781\"
ar$(5)="A\Hilde Buyse\AV. Mediteraneo 58, Coblanca 6\Benidorm\s\966813300\\dokter - Achter apoteek\ma-vr 9-10  / 15-18\"
ar$(4)="A\Alex cars\Calle Lepante\Benidorm\s\965863111\\autohuur\\"
ar$(6)="<eof>"
arptr=6
;------------------------

 If OpenWindow(2, 384, 288, 640, 480, "Contactenlijst", #PB_Window_SystemMenu|#PB_Window_Maximize |#PB_Window_SizeGadget) 
  LVWidth = WindowWidth(2) 
  LVCWidth = Int(LVWidth/(atfields+1)) ; aantal col
    ListIconGadget = ListIconGadget(0, 0, 0, LVWidth, WindowHeight(2), "recnr", LVCWidth, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect) 
    For i=1 To atfields 
      AddGadgetColumn(0, i, fieldnm$(i), LVCWidth) 
    Next  
    
    For j= 1 To arptr-1
      ;If Left(ar$(j),1) <> "D"
        R$=""
        dsd$=RSet(Str(j), 5, "0")     
        R$=R$ + dsd$ + Chr(10)
          For i=2 To atfields+1
            R$ =R$ + StringField(ar$(j), i, "\") + Chr(10)    
          Next
          Debug R$
          AddGadgetItem(0, j-1, R$, 0) 
     ; EndIf    
    Next
  
   Repeat
     Event = WaitWindowEvent()
   Until Event = #PB_Event_CloseWindow
   
EndIf 
End
;----------------------------------------------

  DataSection
Data.s "persbes.tbl"    
Data.i 8
Data.s "Naam:","Adres:","Plaats:","Land:","Telefoon:","Email:","Kategorie:","Divers:" 
EndDataSection



Above code is displaying 5 records in a listicongadget.
The first letter of each record is A or D.
when in the lines: ; If Left(ar$(j),1) <> "D" and ;endif the ; is removed , only lines 1,2 and 4 and 5 should be displayed.
Lines 1 and 2 are, but from the lines AFTER the line starting with a D (line 3) , only the first column is displayed.
In the debug window the complete lines are OK.

Why?
Richard
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: addgadgetitem

Post by STARGÅTE »

you can not add items with die Index : 0, 1, 3, 4. 2 is missing!

use -1 for Position!

Code: Select all

AddGadgetItem(0, -1, R$, 0) 
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: addgadgetitem

Post by t57042 »

Simple if you know.
Thanks
Richard
Skiller
User
User
Posts: 12
Joined: Sun Oct 08, 2006 8:37 pm

Re: addgadgetitem

Post by Skiller »

Hi folks,
I would like to write text in a addgadgetitem() like single letters next to each other,
but It always makes line breaks. How is it possible ?

Thx!!

Code: Select all

If OpenWindow(0, 0, 0, 250, 200, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ; | #PB_Window_Invisible)
  
  EditorGadget(1, 10, 10, WindowWidth(0)-20, WindowHeight(0)-20, #PB_Editor_WordWrap)
  SetActiveGadget(1) ;Focus auf den Editor
  
  
  ;**********************************************************************
  ; Wanted this loop as a text input of single letters next to each other
  ;**********************************************************************
  For i = 0 To 10
    AddGadgetItem(1, -1, Str(i))
  Next
  ;**********************************************************************
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
  
EndIf
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: addgadgetitem

Post by jacdelad »

Please create an own thread for your problem, this thread is about a ListIconGadget and you are using an EditorGadget.
Also, I don't understand the question, something like this:

Code: Select all

If OpenWindow(0, 0, 0, 250, 200, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ; | #PB_Window_Invisible)
  
  EditorGadget(1, 10, 10, WindowWidth(0)-20, WindowHeight(0)-20, #PB_Editor_WordWrap)
  SetActiveGadget(1) ;Focus auf den Editor
  
  
  ;**********************************************************************
  ; Wanted this loop as a text input of single letters next to each other
  ;**********************************************************************
  For i = 0 To 10
    SetGadgetText(1,GetGadgetText(1)+Str(i))
  Next
  ;**********************************************************************
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
  
EndIf
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Skiller
User
User
Posts: 12
Joined: Sun Oct 08, 2006 8:37 pm

Re: addgadgetitem

Post by Skiller »

yes, that´s it. This function was actually the requirement for another code.
This I will cover it in another topic.

Thanks jacdelad,
Post Reply