掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ComboBoxで名前を選択した時に値を取り出すには? (ID:15506)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
値が整数値のようなので Obejctsプロパティで実現できます。 procedure TForm1.FormCreate(Sender: TObject); var SL: TStringList; I : Integer; begin SL:= TStringList.Create; try SL.CommaText:= '東京=4513,横浜=8525,京都=2285,大阪=1515'; for I:= 0 to SL.Count - 1 do ComboBox1.Items.AddObject( SL.Names[I], TObject(StrToIntDef(SL.Values[SL.Names[I]], 0)) ); finally SL.Free; end; end; procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char); begin if (Key = #13) then ShowMessage(IntToStr(Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex]))); end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.