Hugo Bendtner
Members-
Content Count
8 -
Joined
-
Last visited
Everything posted by Hugo Bendtner
-
I've recently been getting to grips with writing custom controls using TFieldDataLink and making them work with TDBCtrlGrid. I've pretty much copied the code from TDBText to get something similar (with differences). I've learnt that I need ControlStyle := ControlStyle + [csReplicatable]; so that I can drop the control onto a TDBCtrlGrid. My problem is that the control shows the data of the active row in the dataset, bot for each row of the dataset. So for instance if I bind to LineNumber field of my dataset of three records, it shows: 1 1 1 And then clicking on the second row shows: 2 2 2 Not: 1 2 3 Snippets of my code: constructor TMyDataLabel.Create(AOwner: TComponent); begin inherited Create(AOwner); ControlStyle := ControlStyle + [csReplicatable]; //Other code FDataLink := TFieldDataLink.Create; FDataLink.Control := Self; FDataLink.OnDataChange := DataChange; end; function TMyDataLabel.GetFieldText: string; begin if FDataLink.Field <> nil then Result := FDataLink.Field.DisplayText else if csDesigning in ComponentState then Result := Name else Result := ''; end; procedure TMyDataLabel.DataChange(Sender: TObject); begin fLabel.Caption := GetFieldText; end; There is clearly something else I need to do to get it to work, but what is it? I'm thinking the DataLink isn't quite correct?
-
Custom Control for TDBCtrlGrid showing only active data
Hugo Bendtner replied to Hugo Bendtner's topic in VCL
Yes, thank you for this. I've overridden the Paint method, and fetch data from different sources depending on the ControlState. procedure TMyDataLabel.Paint; begin if (csPaintCopy in ControlState) and (FDataLink.Field <> nil) then begin fLabel.Caption:= FDataLink.Field.DisplayText; end else fLabel.Caption:= fBoundData; end; -
Having recently upgraded to Delphi 10.4, I'm experimenting with various controls and currently looking at the TControlList (without LiveBindings). A few questions: Using TControlList with vertically aligned controls in a single column, when manually specifying the ItemIndex it jumps to the item, is there any way to make the scrollbars move so that the selected item is displayed at the top of the list? Currently if the item is off screen it scrolls to the item and the item is shown last. Is there any way to catch when the Selected item (ItemIndex) has changed? Or have I got to put in events for both onClick and onKeyPress etc? Is using ItemIndex the only way to find out what item has been selected? I assume I can never scroll through the list of items because they are all virtual?
-
Does anyone know if TControlLists can handle transparency? I would like to have a watermark underneath and whereas TPanels with clNone as their color are essentially transparent, the TControlList displays black. Messing around with ParentColor doesn't have desired results either.
-
Thanks, Serge_G (Google Translate does the trick!). I was fearful that I may have to extend the TControlList class, and that looks to be what you've done, because bizarrely the most useful functions are private.
-
I am exploring usage of the TTitleBarPanel in Delphi 10.4 and am struggling with the styling of the system buttons (which never take on the custom color of the TTitleBarPanel) and attempting to use Custom Buttons (TCaptionButtonItem) these never seem to display, although clicking in their location calls their attached events). Have I got the basics wrong, or is the TTitleBarPanel lacking?
-
Thanks very much, yes in my naivety setting everything to the same color caused the problem. ButtonForegroundColor is what controls the color of the icon inside the button. Again, thanks very much, common sense prevails!
-
Yes, I believe so, see below (with System Buttons ON/True, which seem to always take Windows colors): When System Buttons is Off/False no buttons display, even though you can see 4 in Design Time. I'm currently using these colors just to be obvious with what is going on (I wouldn't seriously be using them in my final application!).