Combobox et fichier texte [RESOLU]
Publié : jeu. 26/févr./2009 18:03
Salut tous le monde, pour un de mes projets je doit charger le contenu d'un fichier texte dans un ComboBoxGadget. Jusque la, pas vraiment de problème j'utilise ce code.
Voici le contenu du fichier texte:
Mais le problème est que quand je clique plusieurs fois sur le ComboBoxGadget, son contenu augmente de plus en plus.
Voici le code complet :
Merci d'avance pour vos réponses.[/code]
Code : Tout sélectionner
If OpenFile(0, "Type.txt")
While Eof(0) = 0
Texte$ = ReadString(0)
AddGadgetItem(#Gadget_Form1_ComboBox2, 0, Texte$)
Wend
CloseFile(0)
Else
MessageRequester("Information","Impossible d'ouvrir le fichier Type.txt!")
EndIf
Code : Tout sélectionner
Type 1
Type 2
Type 3
Type 4
Voici le code complet :
Code : Tout sélectionner
;- Global Variables and Constants
Global BubbleTipStyle.l:BubbleTipStyle=0
;- Window Constants
Enumeration 1
#Window_Form1
EndEnumeration
#WindowIndex=#PB_Compiler_EnumerationValue
;- Gadget Constants
Enumeration 1
;Window_Form1
#Gadget_Form1_ComboBox2
EndEnumeration
#GadgetIndex=#PB_Compiler_EnumerationValue
Procedure.l Window_Form1()
If OpenWindow(#Window_Form1,80,80,259,65,"Work Form1",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
ComboBoxGadget(#Gadget_Form1_ComboBox2,10,20,240,20)
HideWindow(#Window_Form1,0)
ProcedureReturn WindowID(#Window_Form1)
EndIf
EndProcedure
;- Main Loop
If Window_Form1()
quitForm1=0
Repeat
EventID =WaitWindowEvent()
MenuID =EventMenu()
GadgetID =EventGadget()
WindowID =EventWindow()
Select EventID
Case #PB_Event_CloseWindow
If WindowID=#Window_Form1
quitForm1=1
EndIf
Case #PB_Event_Gadget
Select GadgetID
Case #Gadget_Form1_ComboBox2
If OpenFile(0, "Type.txt")
While Eof(0) = 0
Texte$ = ReadString(0)
AddGadgetItem(#Gadget_Form1_ComboBox2, 0, Texte$)
Wend
CloseFile(0)
Else
MessageRequester("Information","Impossible d'ouvrir le fichier Type.txt!")
EndIf
EndSelect
EndSelect
Until quitForm1
CloseWindow(#Window_Form1)
EndIf
End