2

在 TDBComboBox 的帮助文件条目中,它表示所选选项的文本成为该字段的新值。是否有任何类似的控件通过 ItemIndex 而不是文本?(例如,表示枚举类型。)

4

2 回答 2

3

试试 TDBLookupComboBox。查看 ListField、DataField 和 KeyField 属性。

于 2008-11-18T19:28:30.493 回答
2

您可以用数字('0、'1'、'2'、...)填充 TDBComboBox 项目,但将 DBComboBox1.Style 设置为 csOwnerDrawFixed 并编写 OnItemDraw 事件。像这样的东西:

procedure TForm1.DBComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with (Sender as TDBComboBox).Canvas do
  begin
    FillRect(Rect);
    TextRect(Rect, Rect.Left+1, Rect.Top+1, MyValueDescriptions[Index]);
  end;
end;
于 2008-11-18T20:23:12.940 回答