GroupBox problem lazarus / 9-Editor ---------------------------------------------------------------------- pvlazusr · 2011-02-12 00:09 I am having an issue with Groupboxes that I am finding frustrating and seems to defeat the purpose of the Group. I encountered it when using my own component but have found the same issue with some standard components. I have added a control, call it MyStaticText that is a descendent of TStaticText. To this I have added new properties, to keep it simple let us call the new property MyCaption. This takes the caption entered, modifies it then displays it in the caption. For this it does not really matter what the property is or what it does. I do all the package stuff and it appears in the pallet and I can add it to a group box, also the new property is visible in the object inspect and can be accessed by the program. Everything works. I want to put a series of these in the groupbox and fill them from an array. The simple way seems to be to address them as MyGroupBox.Control.MyCaption := MyArray however MyCaption is not recognised. While editing I enter the full point after the Control and I get a drop down list that includes 'Caption' but not 'MyCaption'. When the program runs the MyStaticText object MyCaption can be accessed, it is design time that does not recognise the property and only when it is addressed as a GroupBox control.. I have tried this with regular LCL components such as TButtonPanel where the drop down list includes such properties as Color but not OkButton. The same issues are seen with methods as well as properties. I was under the impression that the GroupBox was intended to allow access to its controls by indexing them but this only seems to apply to a subset of the controls properties. Add a property or method and it cannot be seen at design time when addressed this way. A little help please. ---------------------------------------------------------------------- Phil · 2011-02-12 02:34 Is it possible that the listed properties are for the group box, not your control? I would test this on Delphi. If it works as expected there, that probably indicates a Laz IDE bug that you should report with a bug report. If it does not work as expected there, then it's likely you're doing something that's not supported. Thanks. -Phil ---------------------------------------------------------------------- pvlazusr · 2011-02-12 03:39 I have tried using MyGroupBox.Control(i),Color and the appropriate control changes colour so I do not believe these are the GroupBox properties/procedures. Please note I have used (i) to represent squarebracket i squarebracket as they disappeared from my original post. This MyGroupBox.Control.MyCaption := MyArray should be (using the same change) MyGroupBox.Control(i).MyCaption := MyArray(i) To test on Delphi I would need to set up a virtual machine, install Windows, dig out my old Delphi installer CD, install Delphi and then it would only be version 5 so I am hoping someone might be able to take a look. I'm hoping for some feedback before posting a bug. I would expect a control to be indexable in a GroupBox even an added component. That is the idea of grouping the things in the first place. The issue is why aren't all the properties etc being picked up. ---------------------------------------------------------------------- Phil · 2011-02-12 04:00 Yes, but isn't the type of the Controls property's elements just TControl? Does it make any difference if you cast it like this: MyStaticText(MyGroupBox.Controls). Thanks. -Phil ---------------------------------------------------------------------- pvlazusr · 2011-02-12 21:30 Controls property is derived from TWinControls, would this mean that the only properties are those found in TWinControls and below? That prevents any further properties derived from TWinControls from being referred to. Does it not parse down the controls in the object tree? MyStaticText(MyGroupBox.Controls) Doesn't help as the GroupBox would have several controls in it eg MYStaticText1, MyStaticText2 etc The idea of using Controls[ i ] is to index these controls to avoid having to assign values one by one. BTW how can I put in square brackets without the spaces? ---------------------------------------------------------------------- User137 · 2011-02-12 22:20 Didn't really understand the problem well without seeing code, my thoughts anyway: Code: [Select]TMyButton = class(TButton) public   MyCaption: string; end; var button: TButton; begin   button:=TMyButton.Create(form1);   button.MyCaption:='Test'; // <-- This will not work   TMyButton(button).MyCaption:='Test'; // <-- This will   TMyButton(button).Free; // I assume simple button.Free would not free it completely Most problems would be solved with this if possible in the case: Code: [Select]var button: TMyButton;