⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cellfield.pas

📁 delphi制作表格的控件
💻 PAS
字号:
unit CellField;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, Buttons;

type
  TFormCellField = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ComboBox2: TComboBox;
    ComboBox1: TComboBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    ComboBox3: TComboBox;
    TargetSrc: TDataSource;
    ComboBox4: TComboBox;
    Label4: TLabel;
    procedure FormShow(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    FieldName, DispName: String;
    LinkType, EditType: Integer;
  end;

var
  FormCellField: TFormCellField;

implementation

{$R *.dfm}

procedure TFormCellField.FormShow(Sender: TObject);
var I: Integer;
    S: String;
begin
  ComboBox1.ItemIndex := LinkType;
  ComboBox4.ItemIndex := EditType;
  if not TargetSrc.DataSet.Active then Exit;
  for I:=0 to TargetSrc.DataSet.FieldCount-1 do
  begin
    S := TargetSrc.DataSet.Fields[I].FieldName;
    ComboBox2.Items.Add(S);
    ComboBox3.Items.Add(S);
  end;
  ComboBox2.ItemIndex := ComboBox2.Items.IndexOf(FieldName);
  ComboBox3.ItemIndex := ComboBox3.Items.IndexOf(DispName);
  {for I:=0 to TargetSrc.DataSet.FieldCount-1 do
  begin
    if FieldName = TargetSrc.DataSet.Fields[I].FieldName then Break;
  end;
  if I <= (TargetSrc.DataSet.FieldCount-1) then
    ComboBox2.ItemIndex := I;
  for I:=0 to TargetSrc.DataSet.FieldCount-1 do
  begin
    if DispName = TargetSrc.DataSet.Fields[I].FieldName then Break;
  end;
  if I <= (TargetSrc.DataSet.FieldCount - 1) then
    ComboBox3.ItemIndex := I;}
  ComboBox1Change(nil);
end;

procedure TFormCellField.ComboBox1Change(Sender: TObject);
var Value:Integer;
begin
  Value := ComboBox1.ItemIndex;
  ComboBox2.Enabled := (Value>=1);
  ComboBox3.Enabled := (Value>=2);
  ComboBox4.Enabled := (Value>=2);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -