捐赠 | 广告 | 注册 | 发布 | 上传 | 关于我们    
  沪ICP备05001939号 DELPHI盒子 | 盒子论坛 | 盒子文章 | 盒子问答悬赏 | 最新更新 | 论坛检索 | 下载中心 | 高级搜索    
  精品专区 | 繁體中文 | 奖励公告栏 | 直通车账号登陆 | 关闭GOOGLE广告 | 临时留言    
 
广告
评论:ExComboBox组件附源代码
longjiao1981 20569 2006/1/2 12:34:16
你这个问题还很多呀 1 弹出面板时 窗体为非活动窗体了 2 拖运窗体 面板还在 3 面板不能改变大小
解决后可以发给我不 329654307@QQ.com
chenliang_820 16991 2005/8/16 9:25:51
好东西啊!解决了我的一个大问题!!!谢谢!!
jacktl 16948 2005/8/12 14:02:11
谢谢楼上这位兄弟,但在我的组件中是通过 SelectField 属性来操作所选择那个数据字段的数据,DesignIntf, DesignEditors 这两个是在 X:\Program Files\Borland\Delphi7\Source\ToolsAPI 目录中。
附说明:我在组件中设计了一个 SelectField 属性来选择数据字段的字段名称。这样可以在操作中灵活的获取不同列的数据。
chgs 16947 2005/8/12 13:43:19
将EsoftExComboBox.pas改为下列文件,即不出现上述情况.
//////////
//  EsoftExComboBox.pas
//  组件需求:在原ComboBox中不只可以显示一列数据显示,在应用中需要显示数据的
//          附件列。
//  组件功能:在ComboBox下拉列表中显示多列数据信息。
//  编写时间:2005.6.7
//  作者:罗剑 QQ: 4966374  Email: jacktcx@163.com
//
//  若对该组件有什么好的建议或意见请给偶来信,谢谢!
//////////

unit EsoftExComboBox;

interface

uses
  SysUtils, Classes, Controls, StdCtrls, Forms, DB, ComCtrls, Windows, Grids,
  DBGrids, {DesignIntf, DesignEditors,} Dialogs ;

type
  {TSelectFieldEditer= class(TStringProperty)
    function GetAttributes: TPropertyAttributes; override;
    procedure GetValues(Proc: TGetStrProc); override;
  end;}

  TEsoftExComboBox = class(TCustomComboBox)
  private
    FTmpfrm : TForm;
    FDataSource : TDataSource;
    FDataGridWidth : integer;
    FDataGridHeight : integer;
    FDataColumns: TDBGridColumns;
    FDataGrid : TDBGrid;
    FSelectField : String;
    procedure SelectData(Sender: TObject);
    procedure SetDataSource(const Value: TDataSource);
    procedure SetDataGridHeight(const Value: integer);
    procedure SetDataGridWidth(const Value: integer);
    procedure SetColumns(const Value: TDBGridColumns);
    procedure SetSelectField(const Value: String);
  protected
    procedure DropDown; override;
    function  CreateColumns : TDBGridColumns;
  public
    constructor Create(AOwner : TComponent); override;
    destructor Destory;
  published
    property DataSource : TDataSource read FDataSource write SetDataSource;
    property DataGridWidth  : integer read FDataGridWidth write SetDataGridWidth ;
    property DataGridHeight : integer read FDataGridHeight write SetDataGridHeight ;
    property Columns : TDBGridColumns read FDataColumns write SetColumns;
    property SelectField : String read FSelectField write SetSelectField;
    property Color;
    property Constraints;
    property Ctl3D;
    property BevelEdges;
    property BevelInner;
    property BevelKind default bkNone;
    property BevelOuter;
    property Font;
    property Text;
    property Visible;
    property OnChange;
    property OnClick;
    property OnCloseUp;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnDrawItem;
    property OnDropDown;
    property OnEndDock;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnMeasureItem;
    property OnSelect;
    property OnStartDock;
    property OnStartDrag;    
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('eSoft', [TEsoftExComboBox]);
  //RegisterPropertyEditor(TypeInfo(string), TEsoftExComboBox, 'SelectField', TSelectFieldEditer);
end;

{ TEsoftExComboBox }

constructor TEsoftExComboBox.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  FTmpfrm          := TForm.Create(self);
  FTmpfrm.BorderStyle := bsNone;
  FDataGrid          := TDBGrid.Create(FTmpfrm);
  FDataGrid.Parent    := FTmpfrm;

  FDataGridWidth      := 250;
  FDataGridHeight     := 150;
  FDataGrid.Width     := FDataGridWidth;
  FDataGrid.Height    := FDataGridHeight;
  FDataGrid.Ctl3D     := false;
  FDataGrid.Align     := alClient;
  FDataGrid.Options   := [dgTitles,dgColumnResize,dgColLines,dgRowLines,dgTabs,
          dgRowSelect,dgConfirmDelete,dgCancelOnExit];
  FDataColumns        := CreateColumns;
  FDataGrid.OnDblClick := SelectData;
end;

function TEsoftExComboBox.CreateColumns: TDBGridColumns;
begin
  Result := TDBGridColumns.Create(FDataGrid, TColumn);
end;

destructor TEsoftExComboBox.Destory;
begin
  FDataGrid.Free;
  FTmpfrm.Free;
end;

procedure TEsoftExComboBox.DropDown;
var
  ScreenPoint : TPoint;
begin
  inherited;
  ScreenPoint := Parent.ClientToScreen( Point( self.Left, self.Top+self.Height ));
  with FTmpfrm do
  begin
    Left          := ScreenPoint.X;
    Top          := ScreenPoint.Y;
    Width          := FDataGridWidth;
    Height          := FDataGridHeight;
    FDataGrid.Columns.Assign(FDataColumns);
  end;
  FTmpfrm.Show;
end;

procedure TEsoftExComboBox.SelectData(Sender: TObject);
begin
  Text := FDataGrid.DataSource.DataSet.FieldValues[FSelectField];
  FTmpfrm.Hide;
end;

procedure TEsoftExComboBox.SetColumns(const Value: TDBGridColumns);
begin
  FDataColumns := Value;
end;

procedure TEsoftExComboBox.SetDataGridHeight(const Value: integer);
begin
  if FDataGridHeight <> Value then
  begin
    FDataGridHeight   := Value;
    FDataGrid.Height  := Value;
  end;
end;

procedure TEsoftExComboBox.SetDataGridWidth(const Value: integer);
begin
  if FDataGridWidth <> value then
  begin
    FDataGridWidth    := Value;
    FDataGrid.Width   := Value;
  end;
end;

procedure TEsoftExComboBox.SetDataSource(const Value: TDataSource);
begin
  if FDataSource <> Value then
  begin
    FDataSource          := Value;
    FDataGrid.DataSource  := Value;
  end;
end;

procedure TEsoftExComboBox.SetSelectField(const Value: String);
begin
  FSelectField := Value;
end;

{ TSelectFieldEditer }

{function TSelectFieldEditer.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList, paSortList, paRevertable];
end;  }

{procedure TSelectFieldEditer.GetValues(Proc: TGetStrProc);
var i : integer;
    SelectData : TEsoftExComboBox;
begin
  inherited;
  SelectData := GetComponent(0) as TEsoftExComboBox;
  if SelectData.Columns.Count <>0 then
    for i :=0 to SelectData.Columns.Count-1 do
      Proc(SelectData.Columns.Items[i].FieldName);
end;  }

end.
jacktl 16946 2005/8/12 13:42:26
添加Library Path:
D:\Program Files\Borland\Delphi7\Source\ToolsAPI
chenliang_820 16942 2005/8/12 9:45:31
老兄!运行的时候出现如下错误:
[Fatal Error] Demo.dpr(5): File not found: 'DesignIntf.dcu'

如何解决!
chenliang_820 16941 2005/8/12 9:34:40
谢谢!!!下来学习一下!
感谢斑竹的无私奉献!
第一页 上一页 下一页 最后页 有 7 条纪录 共1页 1 - 7
 用户名:
 密 码:
自动登陆(30天有效)
 
  DELPHI盒子版权所有 1999-2023 V4.01 粤ICP备10103342号-1 更新RSS列表