Probleme de cheminde fichier et d'affichage ( ListBox et RichEdit )
pucenet21
Messages postés26Date d'inscriptionlundi 21 février 2005StatutMembreDernière intervention18 juin 2008
-
2 avril 2005 à 02:21
pucenet21
Messages postés26Date d'inscriptionlundi 21 février 2005StatutMembreDernière intervention18 juin 2008
-
2 avril 2005 à 13:21
je sais pas si le premier post à marcher alors j'en ais refait un
aller encore une petite
bon voila après une aide de la part de Nico j'ais réussi as faire ce que je voulez mais voila un petit souci
explications:
les 2 premières fenêtre sa vas pas de soucie
mais les 2 suivante sa vas pas
quand je click dans le ListBox sur 1 Dt ou 2 Dt il affiche le Doc 1 ou 2 dans mon RichEdit alors qu'il devrais m'afficher le texte Doc 3 ou Doc 4 donc je pence avoir fait une bêtise dans mon code ou oublier quelque chose si quelqu'un peut m'aider merci
<?xml:namespace prefix v ns "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></v:path><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype>
Const
MyTab: Array [0..1] Of String = (
'C:\Nouveau Document texte1.txt', // chemin du doc 1
'C:\Nouveau Document texte2.txt'); // chemin du doc 2
MyTab1: Array [0..1] Of String = (
'C:\Nouveau Document texte3.txt', // chemin du doc 3
'C:\Nouveau Document texte4.txt'); // chemin du doc 4
procedure TForm1.ListBox1Click(Sender: TObject);
begin
// sa se joue ici mais arrive pas à trouver la syntaxe exacte
If (ListBox1.ItemIndex < 0) Then Exit;
If (FileExists(MyTab[ListBox1.ItemIndex])) Then
RichEdit1.Lines.LoadFromFile(MyTab[ListBox1.ItemIndex])
Else ShowMessage('Fichier ' + MyTab[ListBox1.ItemIndex] + ' introuvable !');
end;
procedure TForm1.Button1Click(Sender: TObject);
Var
x: Integer;
Begin
ListBox1.Clear;
For x := 0 To High(MyTab) Do
ListBox1.Items.Add(IntToStr(x + 1) +' Document');
end;
procedure TForm1.Button2Click(Sender: TObject);
Var
x: Integer;
Begin
ListBox1.Clear;
For x := 0 To High(MyTab1) Do
ListBox1.Items.Add(IntToStr(x + 1) +' Dt');
end;
Autre question
si je crée un fichier texte avec disons 5 paragraphe avec un titre as chaque fois et 15 ligne et il possible de faire en sorte que quand je sélectionne une ligne dans mon ListBox je puisse afficher le 3 eme paragraphe ??? De se fichier texte etc.. Si je cliques sur une autre ligne il m'affiche un autre paragraphe du même fichier texte <v:shape id=_x0000_i1026 style="WIDTH: 11.25pt; HEIGHT: 11.25pt" alt="" type="#_x0000_t75"><v:imagedata o:HREF="/imgs2/smile_blush.gif" src="file:///C:\DOCUME~1\Nescafe\LOCALS~1\Temp\msohtml1\01\clip_image002.gif"></v:imagedata></v:shape>
dernière question et il possible d'utiliser une autre sorte de fichier qu'un fichier texte si la deuxième question n'est pas possible exemple un fichier Access merci à tous ceux qui prendrons le temps de me répondre
cs_neko
Messages postés135Date d'inscriptionjeudi 14 août 2003StatutMembreDernière intervention12 octobre 20061 2 avril 2005 à 12:26
Const
MyTab: Array [0..1] Of String = (
'C:\Nouveau Document texte1.txt', // chemin du doc 1
'C:\Nouveau Document texte2.txt'); // chemin du doc 2
MyTab1: Array [0..1] Of String = (
'C:\Nouveau Document texte3.txt', // chemin du doc 3
'C:\Nouveau Document texte4.txt'); // chemin du doc 4
procedure TForm1.ListBox1Click(Sender: TObject);
begin
// sa se joue ici mais arrive pas à trouver la syntaxe exacte
If (ListBox1.ItemIndex < 0) Then Exit;
if(ListBox1.Tag=0)Then Begin
If (FileExists(MyTab[ListBox1.ItemIndex])) Then
RichEdit1.Lines.LoadFromFile(MyTab[ListBox1.ItemIndex])
Else ShowMessage('Fichier ' + MyTab[ListBox1.ItemIndex] + ' introuvable !');
End Else Begin
If (FileExists(MyTab1[ListBox1.ItemIndex])) Then
RichEdit1.Lines.LoadFromFile(MyTab1[ListBox1.ItemIndex])
Else ShowMessage('Fichier ' + MyTab1[ListBox1.ItemIndex] + ' introuvable !');
End;
end;
procedure TForm1.Button1Click(Sender: TObject);
Var
x: Integer;
Begin
ListBox1.Clear;
For x := 0 To High(MyTab) Do
ListBox1.Items.Add(IntToStr(x + 1) +' Document');
//La propriété Tag en soit ne sert a rien, elle est laissée libre pour le programmeur
//Ici
on va s'en servir pour stocker le numéro du tableau ( un pointeur
serait plus judicieux mais j'ai eu peur que ce soit un peu trop
compliqué vu que je ne connais pas ton niveau )
ListBox1.Tag := 0;
end;
procedure TForm1.Button2Click(Sender: TObject);
Var
x: Integer;
Begin
ListBox1.Clear;
For x := 0 To High(MyTab1) Do
ListBox1.Items.Add(IntToStr(x + 1) +' Dt');