掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ComboBoxで選んだ文字列に関係する文字列のみをMemoに表示させる方法は? (ID:11586)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
今のソースです。 procedure TForm1.Button1Click(Sender: TObject); var SL,SL2: TStringList; i: Integer; begin SL := TStringList.Create; SL2 := TStringList.Create; try SL.LoadFromFile('c:\test.txt'); StringGrid1.RowCount := SL.Count; SL2.CommaText := SL.Strings[0]; StringGrid1.ColCount := SL2.Count; for i := 0 to SL.Count - 1 do StringGrid1.Rows[i].CommaText := SL.Strings[i]; ComboBox1.Items.CommaText := StringGrid1.Cols[0].CommaText; Memo1.Lines.Add(StringGrid1.Cols[1].CommaText); Memo2.Lines.Add(StringGrid1.Cols[2].CommaText); Memo3.Lines.Add(StringGrid1.Cols[3].CommaText); Memo4.Lines.Add(StringGrid1.Cols[4].CommaText); finally FreeAndNil(SL2); FreeAndNil(SL); end; end; procedure TForm1.ComboBox1Change(Sender: TObject); var SL,SL2: TStringList; i,j: Integer; begin StringGrid1.Rows[i]; Memo1.Lines.Add(StringGrid1.Cells[1,ComboBox1.ItemIndex]); Memo2.Lines.Add(StringGrid1.Cells[2,ComboBox1.ItemIndex]); Memo3.Lines.Add(StringGrid1.Cells[3,ComboBox1.ItemIndex]); Memo4.Lines.Add(StringGrid1.Cells[4,ComboBox1.ItemIndex]); end; test.txtは、 a1,a2,a3,a4,a5 b1,b2,b3,b4,b5 c1,c2,c3,c4,c5 となっています。 ComboBoxに、a1,b1,c1 Memo1にa2,b2,c2 ・・・ Memo4にa5,b5,c5 と文字列がセットされています。 このまま実行すると、ComboBoxでa1を選んでも、b1を選んでも、c1を選んでも, Memoには表示される順番が変わるだけで全部表示されてしまうんです。 目的は、ComboBoxで選んだ文字列に関係する文字列のみをMemoに表示させたいんです。 ComboBoxでa1を選ぶと ComboBoxでb1を選ぶと ComboBoxでc1を選ぶと Memo1はa2のみ Memo1はb2のみ Memo1はc2のみ Memo2はa3のみ Memo2はb2のみ Memo2はc2のみ Memo3はa4のみ Memo3はb2のみ Memo3はc2のみ Memo4はa5のみ Memo4はb2のみ Memo4はc2のみ と表示させたいんです。 何か良い方法ありませんか? 長くなりましたが、お願いします。
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.