是否存在由 ItemIndex 指定的启用数据的单选组组件?

发布于 2024-07-10 10:05:13 字数 360 浏览 5 评论 0原文

我正在将其中一个表单中的多个组件替换为支持数据的版本,当我的新 TDBRadioGroup 未与分配给它的数字字段链接时,我感到有点惊讶。 事实证明,TDBRadioGroup 的“值”不是存储在 ItemIndex 属性中,而是存储在必须手动填充的 TString 中。 我可以理解这在某些情况下很有用,但是当它仅链接到数字字段时,必须执行以下操作:

   for i := 0 to myRadioGroup.Items.Count - 1 do
      myRadioGroup.Values.Add(intToStr(i));

有点矫枉过正。 有谁知道启用数据的单选组组件将使用 ItemIndex 作为其值参数?

I'm replacing several components in one of my forms with data-enabled versions, and it was a bit of a surprise when my new TDBRadioGroup didn't link up with the numeric field it was assigned to. Turns out that instead of going by the ItemIndex property, TDBRadioGroup's "value" is stored in a TStrings that you have to populate manually. I can understand that that would be useful in some cases, but when it's just linked to a numeric field, having to do something like this:

   for i := 0 to myRadioGroup.Items.Count - 1 do
      myRadioGroup.Values.Add(intToStr(i));

is kinda overkill. Does anyone know of a data-enabled radio group component that will use ItemIndex for its value parameter?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别理我 2024-07-17 10:05:13

您可以专门化 TDBRadioGroup 并按索引添加值,我建议您覆盖该事件
程序已加载; 覆盖;

procedure TMyDBRadioGroup.Loaded; override;

var
  I: Integer;

begin
  inherited;
  Values.Clear;
  for i := 0 toItems.Count - 1 do
    Values.Add(intToStr(i));
end;

You can specialize a TDBRadioGroup and add values By Index, I suggest you override the event
procedure Loaded; override;

procedure TMyDBRadioGroup.Loaded; override;

var
  I: Integer;

begin
  inherited;
  Values.Clear;
  for i := 0 toItems.Count - 1 do
    Values.Add(intToStr(i));
end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文