alogrep 0 Posted June 7, 2023 HI. I have this line of code if ( g.scrollbars =ssBoth) or (g.scrollbars=ssHorizontal) then .... (g is a tstringgrid); I get the error Incompatible styles: Tscrollstyles and Enumeration. If I have only if ( g.scrollbars =ssBoth) then .. (and with only g.scrollbars=ssHorizontal I still get the error) I get no error message. How can I determine if the scrollbars at design time is defined as ssBoth or ssHorizontal? Any help? Share this post Link to post
Remy Lebeau 1398 Posted June 7, 2023 Did you copy/paste the error message as-is? There is no TScrollStyles type in the VCL, only TScrollStyle. Do you, by chance, have a custom/3rd-party unit in your code that defines its own TScrollStyles type? Perhaps also defines its own ssHorizontal constant of that type? Have you tried qualifying the enum values with the enum type? This is particularly important for ssHorizontal, which is defined by both of the System.UITypes.TScrollStyle and System.Classes.TShiftState types. if ( g.ScrollBars = TScrollStyle.ssBoth) or (g.ScrollBars = TScrollStyle.ssHorizontal) then if ( g.ScrollBars = TScrollStyle.ssBoth) then if ( g.ScrollBars = TScrollStyle.ssHorizontal) then Share this post Link to post
programmerdelphi2k 237 Posted June 7, 2023 (edited) @alogrep maybe this way help you better no? // TScrollStyle = System.UITypes.TScrollStyle deprecated 'Use System.UITypes.TScrollStyle'; implementation {$R *.dfm} uses System.TypInfo; type TMyScrollStylesSetOfValues = set of TScrollStyle; // if does not exists, we can create it! TMyHelperScrollStyle = record helper for TScrollStyle function ScrollBarStyleName: string; end; { TMyHelperScrollStyle } function TMyHelperScrollStyle.ScrollBarStyleName: string; begin result := GetEnumName(typeinfo(TScrollStyle), ord(Self)); end; procedure TForm1.Button1Click(Sender: TObject); var LStringGridScrollBarsIsUsingThisValues: TMyScrollStylesSetOfValues; begin StringGrid1.ScrollBars := TScrollStyle.ssBoth; // testing... // LStringGridScrollBarsIsUsingThisValues := [ssBoth, ssHorizontal]; // if (StringGrid1.ScrollBars in LStringGridScrollBarsIsUsingThisValues {or ... [ssBoth, ssHorizontal] } ) then Memo1.Lines.Add('1: ' + StringGrid1.ScrollBars.ScrollBarStyleName) else Memo1.Lines.Add('2: ' + StringGrid1.ScrollBars.ScrollBarStyleName); end; Edited June 7, 2023 by programmerdelphi2k Share this post Link to post
alogrep 0 Posted June 7, 2023 Thanks Remy. Your solution worked. I cannot find anywhere a componet that defines TScrollStyles. Share this post Link to post
programmerdelphi2k 237 Posted June 7, 2023 unit Vcl.StdCtrls.pas and System.UITypes.pas (new IDE) Share this post Link to post