Jump to content

Search the Community

Showing results for tags 'Class'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

There are no results to display.

Forums

  • Welcome to Smart Mobile Studio
    • News and Information
    • Pre-Sales Questions
    • Smart In the Media
    • Smart Contests
    • Meta
  • Smart Mobile Studio Discussion
    • General
    • IDE
    • RTL
    • Code
    • Client Server
    • Platform
    • Graphics
    • Deployment
    • Suggestion box
  • Smart Mobile Studio support
    • Support
    • Bug report
  • General Discussion
    • Pascal
    • Delphi
    • Javascript
    • HTML/HTML5
    • CSS
  • Resources
    • Website
    • Download Smart Mobile Studio

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Company name


Position

Found 1 result

  1. I am trying to create a listbox that has an Image and Label on each item. The image is aligned left, and the label is aligned client. Why doesn't the code below work? I never get anything on the ListBox items (no images or labels) unit Main; interface uses SmartCL.System, SmartCL.Graphics, SmartCL.Components, SmartCL.Forms, SmartCL.Fonts, SmartCL.Borders, SmartCL.Application, SmartCL.Layout, SmartCL.Controls.Listbox, System.Colors; type TfrmMain = class(TW3Form) private {$I 'Main:intf'} fLayout: TLayout; procedure AddItem(Caption: String; Image: String); protected procedure InitializeForm; override; procedure InitializeObject; override; procedure Resize; override; end; implementation uses LBItem; { TForm1 } procedure TfrmMain.AddItem(Caption: String; Image: String); begin var lbItem := W3ListBox.Items[W3ListBox.Add] as TLBItem; lbItem.Caption:= Caption; lbItem.Image:= Image; end; procedure TfrmMain.InitializeForm; begin inherited; // this is a good place to initialize components FLayout:= Layout.Client(W3ListBox); end; procedure TfrmMain.InitializeObject; begin inherited; {$I 'Main:impl'} W3ListBox.ItemClass := TLBItem; W3ListBox.ItemHeight := 32; W3ListBox.Styles.SelectedColor := clSilver; AddItem('One', 'res\1.png'); AddItem('Two', 'res\2.png'); AddItem('Three', 'res\3.png'); AddItem('Four', 'res\4.png'); AddItem('Five', 'res\5.png'); end; procedure TfrmMain.Resize; begin inherited; if Assigned(FLayout) then begin FLayout.Resize(self); end; end; initialization Forms.RegisterForm({$I %FILE%}, TfrmMain); end. unit LBItem; interface uses System.Types, SmartCL.System, SmartCL.Graphics, SmartCL.Components, SmartCL.Forms, SmartCL.Fonts, SmartCL.Borders, SmartCL.Application, SmartCL.Controls.Header, SmartCL.Controls.CheckBox, SmartCL.Controls.Image, SmartCL.Layout, SmartCL.Controls.Label; type TLBItem = class(TW3Form) private {$I 'LBItem:intf'} fLayout: TLayout; procedure SetImage(Value: String); function GetImage: String; procedure SetCaption(Value: String); function GetCaption: String; protected procedure InitializeForm; override; procedure InitializeObject; override; procedure Resize; override; public property Image: String read GetImage write SetImage; property Caption: String read GetCaption write SetCaption; end; implementation { TLBItem } procedure TLBItem.SetCaption(Value: String); begin W3Label.Caption:= Value; end; function TLBItem.GetCaption: String; begin result:= W3Label.Caption; end; procedure TLBItem.SetImage(Value: String); begin W3Image.LoadFromUrl(Value); end; function TLBItem.GetImage: String; begin result:= W3Image.Url; end; procedure TLBItem.InitializeForm; begin inherited; // this is a good place to initialize components Layout.Client([Layout.Left(W3Image), Layout.Left(W3Label)]); end; procedure TLBItem.InitializeObject; begin inherited; {$I 'LBItem:impl'} W3Image.Width:= 32; W3Image.Height:= 32; W3Label.Height:= 32; W3Label.Width:= 32; end; procedure TLBItem.Resize; begin inherited; if Assigned(FLayout) then begin FLayout.Resize(self); end; end; initialization Forms.RegisterForm({$I %FILE%}, TLBItem); end.
×
×
  • Create New...