TNotebook/ja

From Free Pascal wiki
Jump to navigationJump to search

English (en) français (fr) 日本語 (ja) русский (ru)

tnotebook.pngTNotebookは、さまざまなコントロールをページに配置して保持するコンテナを提供するコンポーネントである。実際のノートブックのように、複数のページを持つことができる。TNotebookはTWinControlの派生であり、Component Palette/jaAdditional tab/jaタブで利用できる。

Navigating from page to page

All pages of the TNotebook are listed by the Pages property, a TStrings class which contains the page names. There is also a property Page (note the singular!) which lists the TPage controls into which other controls can be inserted.

Unlike TPageControl the TNotebook does not have tabs. Therefore, navigation between pages is not as easy as with TPageControl:

  • At designtime the pages are listed in the object tree of the Object Inspector under the Notebook node; here the developer can easily switch from page to page.
  • At runtime, special code must be provided to show a specific page; the PageIndex property determines which page is currently visible. Here is an example for application of TNotebook in a tabless, wizard-like form with "Forward"/"Backward" buttons to move from page to page:
procedure TForm1.ForwardBtnClick(Sender: TObject);
begin
  if Notebook1.PageIndex < Notebook1.PageCount-1 then
    Notebook1.PageIndex := Notebook1.PageIndex + 1;
end;

procedure TForm1.BackwardBtnClick(Sender: TObject);
begin
  if Notebook1.PageIndex > 0 then
    Notebook1.PageIndex := Notebook1.PageIndex - 1;
end;

Adding pages

Pages can be added at designtime by right-clicking on the TNotebook component and selecting Add Page from the context menu.

At runtime, a page is added by calling Notebook.Add('new pagename') with the name of the new page as parameter; the function returns the index of the new page. As already noted, the new page itself can be addressed by using the property Notebook.Page[newindex] (note the singular). The following example adds a new page and puts a TMemo on it:

procedure TForm1.NewPageBtnClick(Sender: TObject);
var
  newIndex: Integer;
begin
  newIndex := Notebook1.Pages.Add('New Page');   // use plural!
  with TMemo.Create(self) do
  begin
    Parent := Notebook1.Page[newIndex];           // use singular!
    Align := alClient;
  end;
end;

Removing pages

At designtime, a page can be removed by using the context menu of the TNotebook and selecting the menu item Delete Page.

At runtime, a page is removed by deleting the corresponding index from the Pages list (plural!), or by destroying the Page[index] (singular!) at the specific index

procedure TForm1.DeleteCurrPageBtn(Sender: TObject);
begin
  if Notebook1.PageIndex > -1 then
    Notebook1.Pages.Delete(Notebook1.PageIndex);
    // or: Notebook1.Page[Notebook1.PageIndex].Free
  end;
end;

Similar controls

See also


LCL Components
Component Tab Components
Standard/ja TMainMenu/ja • TPopupMenu/ja • TButton/ja • TLabel/ja • TEdit/ja • TMemo/ja • TToggleBox • TCheckBox/ja • TRadioButton/ja • TListBox/ja • TComboBox/ja • TScrollBar/ja • TGroupBox/ja • TRadioGroup/ja • TCheckGroup/ja • TPanel/ja • TFrame/ja • TActionList/ja
Additional TBitBtn/ja • TSpeedButton/ja • TStaticText/ja • TImage/ja • TShape/ja • TBevel/ja • TPaintBox/ja • TNotebook/ja • TLabeledEdit/ja • TSplitter/ja • TTrayIcon/ja • TControlBar/ja • TFlowPanel/ja • TMaskEdit/ja • TCheckListBox/ja • TScrollBox/ja • TApplicationProperties/ja • TStringGrid/ja • TDrawGrid/ja • TPairSplitter/ja • TColorBox/ja • TColorListBox/ja • TValueListEditor/ja
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator/ja • TDBText/ja • TDBEdit/ja • TDBMemo/ja • TDBImage/ja • TDBListBox/ja • TDBLookupListBox/ja • TDBComboBox/ja • TDBLookupComboBox/ja • TDBCheckBox/ja • TDBRadioGroup/ja • TDBCalendar/ja • TDBGroupBox/ja • TDBGrid/ja • TDBDateTimePicker/ja
Data Access TDataSource/ja • TCSVDataSet/ja • TSdfDataSet/ja • TBufDataset/ja • TFixedFormatDataSet/ja • TDbf/ja • TMemDataset/ja
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery/ja • TSQLTransaction/ja • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection/ja • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport_Classes • TPSImport_DateUtils • TPSImport_ComObj • TPSImport_DB • TPSImport_Forms • TPSImport_Controls • TPSImport_StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu