const IndicatorWidth = 11;procedure TCustomDBGrid.SetColumnAttributes; var I: Integer; begin for I := 0 to FColumns.Count-1 do with FColumns[I] do begin TabStops[I + FIndicatorOffset] := Showing and not ReadOnly and DataLink.Active and Assigned(Field) and not (Field.FieldKind = fkCalculated) and not ReadOnlyField(Field); ColWidths[I + FIndicatorOffset] := Width; end; if (dgIndicator in Options) then ColWidths[0] := IndicatorWidth; end;
dbgrid控件没有实现对这个属性操作的借口和函数; 楼主真的需要的话可以自己另外从TDBGrid类中自己继承一个控件;从新实现对该属性的赋值; unit LXDBGrid;interfaceuses Windows, Messages, SysUtils, Classes, Controls, Grids, DBGrids;type TLXDBGrid = class(tdbgrid) private { Private declarations } protected procedure SetColumnAttributes; override; { Protected declarations } public { Public declarations } published { Published declarations } end;procedure Register;implementationprocedure Register; begin RegisterComponent('Test',[TADBGrid]); end;{ TLXDBGrid }procedure TLXDBGrid.SetColumnAttributes; begin inherited; if (dgIndicator in Options) then ColWidths[0] := 200; end;end.
IndicatorWidth = 11;procedure TCustomDBGrid.SetColumnAttributes;
var
I: Integer;
begin
for I := 0 to FColumns.Count-1 do
with FColumns[I] do
begin
TabStops[I + FIndicatorOffset] := Showing and not ReadOnly and DataLink.Active and
Assigned(Field) and not (Field.FieldKind = fkCalculated) and not ReadOnlyField(Field);
ColWidths[I + FIndicatorOffset] := Width;
end;
if (dgIndicator in Options) then
ColWidths[0] := IndicatorWidth;
end;
楼主真的需要的话可以自己另外从TDBGrid类中自己继承一个控件;从新实现对该属性的赋值;
unit LXDBGrid;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, Grids, DBGrids;type
TLXDBGrid = class(tdbgrid)
private
{ Private declarations }
protected
procedure SetColumnAttributes; override;
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponent('Test',[TADBGrid]);
end;{ TLXDBGrid }procedure TLXDBGrid.SetColumnAttributes;
begin
inherited;
if (dgIndicator in Options) then
ColWidths[0] := 200;
end;end.