简体   繁体   English

如何在C ++ Builder中使用Delphi“in”运算符

[英]How to use Delphi “in” operator in C++ Builder

I'm a newbie programmer. 我是新手程序员。 I need to use Delphi's in operator in C++ Builder XE like this: 我需要使用Delphi的in运营商在C ++ Builder的XE是这样的:

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? 如何在C ++ Builder中做到这一点?

Thanks in advance. 提前致谢。

Use the Contains method to check if a set contains a specific element: 使用Contains方法检查集合是否包含特定元素:

if( DBGrid->Options.Contains(dgColLines) )
  TotalColumnWidth = TotalColumnWidth + ColumnCount;

Looking the the property in question, TDBGrid.Options , its type is TDBGridOptions which is defined as: 查看有问题的属性TDBGrid.Options ,其类型为TDBGridOptions ,定义为:

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. 如您所见,C ++ Builder使用模板System::Set<T, minEl, maxEl>来模拟Delphi集类型。

All of the functionality available using the built in Delphi set operators is exposed through the methods of Set . 使用内置的Delphi集合运算符提供的所有功能都通过Set方法公开。 Specifically to this question, set membership is testing using Contains() . 具体到这个问题,设置成员资格正在使用Contains()进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM