How to use Delphi "in" operator in C++ Builder
Asked Answered
R

2

8

I'm a newbie programmer. I need to use Delphi's in operator in C++ Builder XE like this:

if (dgColLines in DBGrid->Options)
    // include vertical lines in total (one per column)
    TotalColumnWidth = TotalColumnWidth + ColumnCount;
if (dgColLines **in** DBGrid->Options)

How to do that in C++ Builder?

Thanks in advance.

Roving answered 11/2, 2013 at 10:44 Comment(1)
Perhaps Language Support for the VCL in the C++ Builder documentation will help find equivalents.Dyal
I
14

Use the Contains method to check if a set contains a specific element:

if( DBGrid->Options.Contains(dgColLines) )
  TotalColumnWidth = TotalColumnWidth + ColumnCount;
Inoculum answered 11/2, 2013 at 10:50 Comment(0)
D
9

Looking the the property in question, TDBGrid.Options, its type is TDBGridOptions which is defined as:

typedef System::Set<TDBGridOption, TDBGridOption::dgEditing,
    TDBGridOption::dgTitleHotTrack> TDBGridOptions;

As you can see, C++ Builder uses the template System::Set<T, minEl, maxEl> to emulate Delphi set types.

All of the functionality available using the built in Delphi set operators is exposed through the methods of Set. Specifically to this question, set membership is testing using Contains().

Dampproof answered 11/2, 2013 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.