home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kolekce / d456 / DCSLIB25.ZIP / DCDBGridEdit.pas < prev    next >
Pascal/Delphi Source File  |  2001-06-20  |  2KB  |  82 lines

  1. {
  2.  BUSINESS CONSULTING
  3.  s a i n t - p e t e r s b u r g
  4.  
  5.          Components Library for Borland Delphi 4.x, 5.x
  6.          Copyright (c) 1998-2000 Alex'EM
  7.  
  8. }
  9. unit DCDBGridEdit;
  10.  
  11. interface
  12. {$I DCConst.inc}
  13.  
  14. uses
  15.   {$IFDEF DELPHI_V6}
  16.     DesignIntf, DesignEditors, DesignWindows,
  17.   {$ELSE}
  18.     Dsgnintf, DsgnWnds,
  19.   {$ENDIF} 
  20.   Classes;
  21.  
  22. type
  23.   TDBGridDataField = class(TStringProperty)
  24.   public
  25.     function  GetAttributes: TPropertyAttributes; override;
  26.     procedure GetValueList(List: TStrings);
  27.     procedure GetValues(Proc: TGetStrProc); override;
  28.   end;
  29.  
  30. implementation
  31. uses DCDBGrids;
  32.  
  33. type
  34.  TPrivateDCDBGrid = class(TDCCustomDBGrid)
  35.  end;
  36.  
  37. {DataField Property Editor}
  38. function TDBGridDataField.GetAttributes: TPropertyAttributes;
  39.  var
  40.   gs: TColumn;
  41. begin
  42.   Result := [paValueList, paSortList, paMultiSelect];
  43.   gs := GetComponent(0) as TColumn;
  44.   try
  45.     if not ((gs <> Nil) and (gs.Grid <> nil) and
  46.       (TPrivateDCDBGrid(gs.Grid).DataSource <> nil) and
  47.       (TPrivateDCDBGrid(gs.Grid).DataSource.DataSet <> nil))
  48.     then
  49.       Result :=  Result - [paValueList];
  50.   except
  51.     Result :=  Result - [paValueList];
  52.   end;
  53. end;
  54.  
  55. procedure TDBGridDataField.GetValueList(List: TStrings);
  56.  var
  57.   gs: TColumn;
  58. begin
  59.   gs := GetComponent(0) as TColumn;
  60.   if (gs <> Nil) and (gs.Grid <> nil) and
  61.      (TPrivateDCDBGrid(gs.Grid).DataSource <> nil) and
  62.      (TPrivateDCDBGrid(gs.Grid).DataSource.DataSet <> nil)
  63.   then
  64.     TPrivateDCDBGrid(gs.Grid).DataSource.DataSet.GetFieldNames(List);
  65. end;
  66.  
  67. procedure TDBGridDataField.GetValues(Proc: TGetStrProc);
  68.  var
  69.   I: Integer;
  70.   Values: TStringList;
  71. begin
  72.   Values := TStringList.Create;
  73.   try
  74.     GetValueList(Values);
  75.     for I := 0 to Values.Count - 1 do Proc(Values[I]);
  76.   finally
  77.     Values.Free;
  78.   end;
  79. end;
  80.  
  81. end.
  82.