[Delphi] ListBoxをスクロールさせる
ListBoxのTopIndexプロパティを設定します。
TopIndexプロパティを使うと、リストボックスの一番上に表示したい項目を設定することができます。
ListBoxのTopIndexプロパティを設定します。
TopIndexプロパティを使うと、リストボックスの一番上に表示したい項目を設定することができます。
ListBoxに横スクロールバーを表示する例です。ListBoxの中で一番、幅の長いアイテムを見つけてから、それにあわせて横スクロールバーを表示しています。
procedure TForm1.Button1Click(Sender: TObject);
var
i:Integer;
MaxWidth:Integer;
TextWidth:Integer;
begin
//一番、幅の長い文字列を調べる
MaxWidth:=0;
for i:=0 to ListBox1.Items.Count-1 do begin
TextWidth:=ListBox1.Canvas.TextWidth(ListBox1.Items[i]);
if (MaxWidth < TextWidth) then MaxWidth:=TextWidth;
end;
//横スクロールバーを表示
ListBox1.Perform (LB_SETHORIZONTALEXTENT, MaxWidth+10, 0);
end;
ActiveX | C++Builder | C++言語・Pascal言語 | Delphi | TActionList | TColor | TEdit | TeX | TForm | TIniFile | TLabel | TListBox | TListView | TMemo | TProgressBar | TSplitter | TStatusBar | TStringGrid | TTrackBar | TWebBrowser | Windows | その他 | アルゴリズム | システム関連 | ネットワーク関連 | ファイル、フォルダの処理 | フォント関連 | フォーム・ダイアログ関連 | フリーソフト | プログラミング全般 | マウス、キーボードの処理 | 技術文書 | 文字列の処理 | 日付時刻の処理 | 画像関連 | 開発環境(IDE)関連