Listbox et items selectionné

Résolu
shell13010 Messages postés 73 Date d'inscription mardi 3 avril 2007 Statut Membre Dernière intervention 12 mai 2013 - 6 avril 2009 à 16:13
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 - 7 avril 2009 à 03:51
Bonjour a tous,


je me trouve fasse a un probleme que j'arrive pas a resoudre


j'ai un listbox et je voudrais que quand une personne click sur une
items me renvoie le string en decimal voici mon code qui renvoie la
premiere items mais j'arrive pas a renvoyer nimporte quel item

procedure TForm4.ListBox1Click(Sender: TObject);

var S:string;

I:integer;

Conv:string;

begin

S:=ListBox1.Items.Strings[0]; //va me renvoyer l'items 0 //ici et mon probleme

     for i:=1 to length(s) do Conv:=Conv+inttostr(ord(s[i]))+',';

   edit2.text:=(Conv); //me renvoie le mot en decimal

showmessage(Choix(ListBox1));

end;


comment je pourrais enlever le 0 pour que l'item 2 ou 3 etc... peut etre convertie?


merci d'avance pour votre aide...

6 réponses

cs_cantador Messages postés 4720 Date d'inscription dimanche 26 février 2006 Statut Modérateur Dernière intervention 31 juillet 2021 13
6 avril 2009 à 17:03
bonjour,

function RenvoiDec: string;
var
  S: string;
  i, j: integer;
  Conv: string;
begin
  with Form1 do
    for i := 0 to ListBox1.Items.Count - 1 do
      if ListBox1.Selected[i] then
      begin
        S := ListBox1.Items.Strings[i];
        for j := 1 to length(S) do
          Conv := Conv + IntToStr(ord(S[j])) + ',';
        Result := Conv;
      end;
end;


procedure TForm1.ListBox1Click(Sender: TObject);
begin
  Edit1.Text := RenvoiDec;
end;

cantador
1
Rejoignez-nous