Procedure TFrmDbMb.FormCreate( Sender: TObject );
Var
aColumn: TdxDBTreeListColumn;
Begin
Inherited;
If Dbg1.ColumnCount > 0 Then
Begin
//在不改变原来代码的情况下-加入自动产生序号列的功能
If Trim( Dbg1.Columns[0].FieldName ) <> '' Then
Begin
aColumn := Dbg1.CreateColumn( TdxDBGridColumn );
With aColumn Do
Begin
BandIndex := 0;
ColIndex := 0;
Name := 'DBGrDBXh';
Caption := '序号';
DisableEditor := True;
OnCustomDrawCell := Self.DoCustomDrawXhCell;
End;
End;
End;
End;
Procedure TFrmDbMb.DoCustomDrawXhCell( Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn;
ASelected, AFocused, ANewItemRow: Boolean; Var AText: String;
Var AColor: TColor; AFont: TFont; Var AAlignment: TAlignment;
Var ADone: Boolean );
Begin
AText := IntToStr( ANode.Index + 1 );
End;