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

📄 iwdbadvwebgridde.pas

📁 TMS IntraWEb增强控件TMSIntraWeb_v2.3.2.1_D2007.rar
💻 PAS
字号:
{***************************************************************************}
{ TMS IntraWeb Component Pack Pro                                           }
{ for Delphi & C++Builder                                                   }
{ version 2.2                                                               }
{                                                                           }
{ written by TMS Software                                                   }
{            copyright ?2002 - 2004                                        }
{            Email : info@tmssoftware.com                                   }
{            Web : http://www.tmssoftware.com                               }
{                                                                           }
{ The source code is given as is. The author is not responsible             }
{ for any possible damage done due to the use of this code.                 }
{ The component can be freely used in any application. The complete         }
{ source code remains property of the author and may not be distributed,    }
{ published, given or sold in any form as such. No parts of the source      }
{ code can be included in any other component or application without        }
{ written authorization of the author.                                      }
{***************************************************************************}

unit IWDBAdvWebGridDE;

{$I TMSDEFS.INC}

interface

uses
  Classes, IWDBAdvWebGrid, DB, IWGridGallery, Forms,DesignIntf, DesignEditors,
{$IFNDEF LINUX}
  IWHTMLDE, IWTMSBase
{$ENDIF}

//{$IFDEF DELPHI6_LVL}
//  DesignIntf, DesignEditors
//{$ELSE}
//  DsgnIntf
//{$ENDIF}
 ;


type
  TIWDBFieldNameProperty = class(TStringProperty)
  public
    function GetAttributes:TPropertyAttributes; override;
    procedure GetValues(Proc:TGetStrProc); override;
  end;

  TIWDBAdvWebGridEditor = class(TDefaultEditor)
  protected
//  {$IFNDEF DELPHI6_LVL}
//    procedure EditProperty(PropertyEditor: TPropertyEditor;
//      var Continue, FreeEditor: Boolean); override;
//  {$ELSE}
    procedure EditProperty(const PropertyEditor: IProperty; var Continue: Boolean); override;
//  {$ENDIF}
  public
    function GetVerb(index:integer):string; override;
    function GetVerbCount:integer; override;
    procedure ExecuteVerb(Index:integer); override;
  end;

procedure Register;

implementation

uses
  SysUtils, Dialogs;

//{$IFDEF DELPHI6_LVL}
procedure TIWDBAdvWebGridEditor.EditProperty(const PropertyEditor: IProperty; var Continue: Boolean);
//{$ELSE}
//procedure TIWDBAdvWebGridEditor.EditProperty(PropertyEditor: TPropertyEditor;
//  var Continue, FreeEditor: Boolean);
//{$ENDIF}
var
  PropName: string;
begin
  PropName := PropertyEditor.GetName;
  if (CompareText(PropName, 'COLUMNS') = 0) then
  begin
    PropertyEditor.Edit;
    Continue := False;
  end;
end;


function TIWDBFieldNameProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList,paSortList];
end;

procedure TIWDBFieldNameProperty.GetValues(Proc:TGetStrProc);
var
  FDataSource: TDataSource;
  FDataSet: TDataSet;
  st: TStringList;
  i: Integer;
begin
  FDataSource := nil;

  if GetComponent(0) is TTIWDBWebGridColumn then
  begin
    FDataSource := TTIWDBAdvWebGrid(TTIWDBWebGridColumns((GetComponent(0) as TTIWDBWebGridColumn).Collection).Grid).DataSource;
  end;

  if not Assigned(FDataSource) then
    Exit;

  FDataSet := FDataSource.DataSet;

  if not Assigned(FDataSet) then
    Exit;

  st := TStringList.Create;
  FDataSet.GetFieldNames(st);
  for i := 1 to st.Count do Proc(st.Strings[i - 1]);
  st.Free;
end;


procedure TIWDBAdvWebGridEditor.ExecuteVerb(Index: integer);
var
  compiler: string;
  Gallery: TGridGallery;
begin
  case Index of
  0:begin
    {$IFDEF VER130}
    {$IFDEF BCB}
    compiler := 'C++Builder 5';
    {$ELSE}
    compiler := 'Delphi 5';
    {$ENDIF}
    {$ENDIF}
    {$IFDEF VER140}
      {$IFDEF BCB}
      compiler := 'C++Builder 6';
      {$ELSE}
      compiler := 'Delphi 6';
      {$ENDIF}
    {$ENDIF}

    {$IFDEF VER150}
      compiler := 'Delphi 7';
    {$ENDIF}

    {$IFDEF LINUX}
    {$IFDEF VER140}
      compiler := 'Kylix 2';
    {$ENDIF}
    {$IFDEF VER150}
      compiler := 'Kylix 3';
    {$ENDIF}

    {$ENDIF}

    MessageDlg(Component.ClassName+' version '+(Component as TTIWCustomDBAdvWebGrid).GetVersionString+' for '+compiler+#13#10'?2002 - 2004 by TMS software',
               mtinformation,[mbok],0);
    end;
  1:begin
      ForceDirectories(GetProgramFiles + '\tmssoftware\TMSIWPRO\Preferences\DBGrids\');
      Gallery := TGridGallery.Create(Application);
      Gallery.Component := Component;
      Gallery.FilePath := GetProgramFiles + '\tmssoftware\TMSIWPRO\Preferences\DBGrids\';
      Gallery.FillList;
      Gallery.ShowModal;
      Gallery.Free;
      Designer.Modified;

    end;

  end;
end;

function TIWDBAdvWebGridEditor.GetVerb(Index: integer): string;
begin
  case Index of
  0:Result := '&About';
  1:Result := 'Gallery';
  end;
end;

function TIWDBAdvWebGridEditor.GetVerbCount: integer;
begin
  Result := 2;
end;


procedure Register;
begin
  {$IFNDEF LINUX}
  RegisterPropertyEditor(TypeInfo(string), TTIWDBWebGridColumn, 'Template', TIWHTMLStringProperty);
  {$ENDIF}
  RegisterPropertyEditor(TypeInfo(string),TTIWDBWebGridColumn,'DataField',TIWDBFieldNameProperty);
  RegisterPropertyEditor(TypeInfo(string),TTIWDBWebGridColumn,'URLTextField',TIWDBFieldNameProperty);  
  RegisterComponentEditor(TTIWDBAdvWebGrid,TIWDBAdvWebGridEditor);
  RegisterComponentEditor(TTIWDBAdvDetailWebGrid,TIWDBAdvWebGridEditor);  
end;

end.

⌨️ 快捷键说明

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