我想做一个控件,用ActiveForm,这个可以吗??????上面放了一个TCheckListBoxk,用来控件Grid中列的显示与隐藏和字段显示顺序,我想把他做成一个控件,有一个TCustomGrid类型的私有成员变量,用Grid属性来访问它,但是为什么安装后没有Grid这个属性,听说要用Type Library来定义控件的属性,但如果用Type Library如何才能建一个Grid类型的成员呢????真的不明白,请大家帮帮忙,谢谢大侠了~~~~~
解决方案 »
- 如何列出控件的事件列表?
- “属性TableName设为Demo.db,Demo.db中包含一个名字是Graph的Blob字段”是什么意思?
- ActiveForm中包含了一个OCX,为什么不能调用?谢谢
- 高分求助!
- 肥水不流外人田,MOP上有MM找BF了,还《很想找个程序员男朋友》
- 請問有懂VB 或者精通Inno Setup的朋友嗎?
- DBGrid在进行某项操作后要隐藏中间的某一条记录(使它不可见),不知有没有什么办法?当然是不希望删除掉它再刷新的那种操作。
- 如何自定义一个表示符?
- sql问题,如何取出在满足条件的记录中的最小值。
- Delphi 的 BUG???
- 关于FreeAndNil的问题
- 如何将数值写入相关字段???
<<delphi6 開發人員指南>>
or
<<delphi 參透>>
SysUtils, Classes, Controls, StdCtrls, CheckLst;type
PStr = ^String;
TArrayColumn = Array of TColumn; TCheckListBoxGridx = class(TCheckListBox)
private
{ Private declarations }
FGrid : TCustomGrid;
FLockCols : TArrayColumn;
FResult : Integer;
protected
{ Protected declarations }
function Get_Grid: TCustomGrid; safecall;
function Get_LockCol : TArrayColumn;safecall;
function Get_Result: Integer; safecall;
function IsLock(FieldName : String) : Boolean;safecall;
procedure Set_Grid(const AGrid : TCustomGrid); safecall;
procedure Let_GridColList;safecall;
procedure Set_LockCol(Columns : TArrayColumn);
procedure Set_Result(AResult: Integer); safecall;
procedure Set_GridCol;safecall;
public
{ Public declarations }
published
{ Published declarations }
procedure ColUp;safecall;
procedure ColDown;safecall;
property Grid : TCustomGrid read Get_Grid write Set_Grid;
property Result : Integer read Get_Result write Set_Result;
end;procedure Register;implementation
function TCheckListBoxGridx.Get_Grid: TCustomGrid;
begin
Result := FGrid;
end;function TCheckListBoxGridx.Get_LockCol : TArrayColumn;
begin
Result := FLockCols;
end;function TCheckListBoxGridx.Get_Result: Integer;
begin
Result := FResult;
end;function TCheckListBoxGridx.IsLock(FieldName : String) : Boolean;
var
I : Integer;
begin
Result := True;
for I := Low(FLockCols) to High(FLockCols) do
if FieldName = TColumn(FLockCols[I]).FieldName then Exit;
Result := False;
end;
procedure TCheckListBoxGridx.Set_Grid(const AGrid : TCustomGrid);
begin
if AGrid <> nil then
FGrid := AGrid;
end;procedure TCheckListBoxGridx.Let_GridColList;
var
I : Integer;
AGridTemp : TDBGrid;
P : PStr;
ColCaption : String;
ColVisible : Boolean;
begin
CLB_Col.Items.Clear;
if FGrid = nil then Exit;
AGridTemp := TDBGrid(FGrid);
for I := 0 to AGridTemp.Columns.Count - 1 do
begin
New(P);
P^ := AGridTemp.Columns[I].FieldName;
ColCaption := AGridTemp.Columns[I].Title.Caption;
ColVisible := AGridTemp.Columns[I].Visible;
CLB_Col.Items.AddObject(ColCaption, TObject(P));
CLB_Col.Checked[I] := ColVisible
end;
end;procedure TCheckListBoxGridx.Set_LockCol(Columns : TArrayColumn);
begin
FLockCols := Columns;
end;procedure TCheckListBoxGridx.Set_Result(AResult: Integer);
begin
FResult := AResult;
if FResult = 1 then
Set_GridCol;
end;procedure TCheckListBoxGridx.Set_GridCol;
var
AGridTemp : TDBGrid;
Col : TColumn;
I : Integer;
begin
AGridTemp := TDBGrid(FGrid);
AGridTemp.Columns.Clear;
for I := 0 to CLB_Col.Items.Count - 1 do
begin
Col := AGridTemp.Columns.Add;
Col.FieldName := String(PStr(CLB_Col.Items.Objects[I])^);
Col.Title.Caption := CLB_Col.Items.Strings[I];
AGridTemp.Columns[I].Visible := CLB_Col.Checked[I];
end;
end;procedure TCheckListBoxGridx.ColUp;
var
Source, Cause, CurrString : String;
CurrObject : TObject;
begin
try
with CLB_Col do
begin
if ItemIndex < 0 then Exit;
CurrString := Items.Strings[ItemIndex];
CurrObject := Items.Objects[ItemIndex];
if IsLock(String(PStr(CurrObject)^)) then Exit;
Items.Strings[ItemIndex] := Items.Strings[ItemIndex - 1];
Items.Objects[ItemIndex] := Items.Objects[ItemIndex - 1];
Items.Strings[ItemIndex - 1] := CurrString;
Items.Objects[ItemIndex - 1] := CurrObject;
ItemIndex := ItemIndex - 1;
end;
except
end;
end;procedure TCheckListBoxGridx.ColDown;
var
Source, Cause, CurrString : String;
CurrObject : TObject;
begin
try
with CLB_Col do
begin
if ItemIndex < 0 then Exit;
if ItemIndex + 1 = Items.Count then Exit;
CurrString := Items.Strings[ItemIndex];
CurrObject := Items.Objects[ItemIndex];
if IsLock(String(PStr(CurrObject)^)) then Exit;
Items.Strings[ItemIndex] := Items.Strings[ItemIndex + 1];
Items.Objects[ItemIndex] := Items.Objects[ItemIndex + 1];
Items.Strings[ItemIndex + 1] := CurrString;
Items.Objects[ItemIndex + 1] := CurrObject;
ItemIndex := ItemIndex + 1;
end;
except
end;
end;procedure Register;
begin
RegisterComponents('Samples', [TCheckListBoxGridx]);
end;end.
请大家帮帮忙说一下自己解决的办法或思路,感激.~~~~