Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Search Forums » Search Results » View Thread |
Messages 1 to 10 of 10 total |
Label in TPanel |
Sun, Oct 15 2017 7:51 PM | Permanent Link |
KimHJ Comca Systems, Inc | I'm trying to create a label inside a TPanel. I get an error at: MyPanel := FindComponent('PT' + Ticketnum) as TPanel; var MyPanel: TPanel; begin PickScrollPanel.BeginUpdate; try with TPanel.Create(PickScrollPanel) do begin Layout.Position:=lpTopLeft; Layout.Consumption:=lcRight; Layout.Overflow:=loBottom; Background.Fill.Color:=clLightGreen; CaptionBar.Background.Fill.Color:=clDarkGreen; CaptionBar.Caption:='Ticket '+Ticketnum; CaptionBar.AllowMinimize:=True; Captionbar.AllowClose := False; CaptionBar.AllowMove:=False; CaptionBar.Height := 22; CaptionBar.Font.Style.Bold := True; Width:=180; Height:=150; Margins.Left:=5; Margins.Top:=5; Name := 'PT' + Ticketnum; end; MyPanel := FindComponent('PT' + Ticketnum) as TPanel; with TLabel.Create(MyPanel) do begin Layout.Position:=lpTopLeft; Layout.Consumption:=lcRight; Layout.Overflow:=loBottom; Margins.Top := 3; Margins.Left := 3; Margins.Right := 3; Margins.Bottom := 3; Name := 'PTLB' + Ticketnum; Caption := 'This a test\r\n and this is a new line'; Font.Color := clElevateBlue; Parent := MyPanel; end; finally PickScrollPanel.EndUpdate; end; Thanks for any help. Kim |
Mon, Oct 16 2017 1:31 AM | Permanent Link |
Michael Dreher | KimHJ wrote: // I get an error at: MyPanel := FindComponent('PT' + Ticketnum) as TPanel; The help says on type casting: // Language Reference / Casting Types: // [casting] is accomplished by enclosing the target value with the target type name and parentheses. So this will work: MyPanel := TPanel(FindComponent('PT' + Ticketnum)); I'am not sure if the syntax ( <expression> "as" <type> ) is valid. Although "as" is shown in the keyword list. Michael Dreher |
Mon, Oct 16 2017 4:23 AM | Permanent Link |
Matthew Jones | I do wish "with" would die. But it does seem odd to have the panel reference there, and then not be able to use it directly afterward. MyPanel := TPanel.Create(PickScrollPanel); with MyPanel do begin ... -- Matthew Jones |
Mon, Oct 16 2017 11:22 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew, << I do wish "with" would die. But it does seem odd to have the panel reference there, and then not be able to use it directly afterward. >> As far as I can see, that's not the issue. The issue is the use of "as" for typecasting. Tim Young Elevate Software www.elevatesoft.com |
Mon, Oct 16 2017 11:23 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Kim, << I'm trying to create a label inside a TPanel. I get an error at: MyPanel := FindComponent('PT' + Ticketnum) as TPanel; >> I'm not sure why the "as" operator wasn't implemented, but it appears that this is indeed the case. For now the workaround is to use the direct cast, as Michael indicated. Tim Young Elevate Software www.elevatesoft.com |
Mon, Oct 16 2017 12:13 PM | Permanent Link |
Matthew Jones | Tim Young [Elevate Software] wrote: > << I do wish "with" would die. But it does seem odd to have the panel reference there, and then not be able to use it directly afterward. >> > > As far as I can see, that's not the issue. The issue is the use of "as" for typecasting. Sure, I was just picking up on something I saw as illogical. Particularly as it then eliminates the need for the bad cast that was failing too. -- Matthew Jones |
Mon, Oct 16 2017 1:44 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew, << Sure, I was just picking up on something I saw as illogical. Particularly as it then eliminates the need for the bad cast that was failing too. >> Sorry, I read your post wrong - I thought you were referring to the end of the first "with" block, when you were referring to the usage of MyPanel at the *beginning* of the first "with" block. Tim Young Elevate Software www.elevatesoft.com |
Mon, Oct 16 2017 1:45 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew, And yes, it would eliminate the necessity of the cast in the first place. Tim Young Elevate Software www.elevatesoft.com |
Mon, Oct 16 2017 5:58 PM | Permanent Link |
KimHJ Comca Systems, Inc | Michael Dreher wrote: >>So this will work: MyPanel := TPanel(FindComponent('PT' + Ticketnum)); I'am not sure if the syntax ( <expression> "as" <type> ) is valid. Although "as" is shown in the keyword list.<< I already tried that before i posted, it will compile but the MyPanel is nil. Kim |
Mon, Oct 16 2017 8:52 PM | Permanent Link |
KimHJ Comca Systems, Inc | "Matthew Jones" wrote: >> MyPanel := TPanel.Create(PickScrollPanel); with MyPanel do begin<< Thanks Matthew that works. Kim |
This web page was last updated on Thursday, December 5, 2024 at 09:15 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |