vladman
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Код: .pas interface type TForm20 = class(TForm) cxGrid1DBTableView1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1: TcxGrid; dxMemData1: TdxMemData; DataSource1: TDataSource; dxMemData1Field1: TStringField; cxGrid1DBTableView1RecId: TcxGridDBColumn; cxGrid1DBTableView1Field1: TcxGridDBColumn; cxGrid1DBTableView1Column1: TcxGridDBColumn; procedure FormCreate(Sender: TObject); private function FileToString(AFileName: string): string; procedure DoLoadImageForEachRow(ARowIndex: Integer; ARowInfo: TcxRowInfo); public end; implementation function TForm20.FileToString(AFileName: string): string; var vStream: TFileStream; vString: string; begin vStream := TFileStream.Create(AFileName, fmOpenRead or fmShareDenyNone); try vStream.Position := 0; SetLength(vString, vStream.Size); vStream.ReadBuffer(Pointer(vString)^, vStream.Size); finally vStream.Free; end; Result := vString; end; procedure TForm20.DoLoadImageForEachRow(ARowIndex: Integer; ARowInfo: TcxRowInfo); begin cxGrid1DBTableView1.DataController.Values[ARowInfo.RecordIndex, cxGrid1DBTableView1Column1.Index] := FileToString(Format('c:\File%d.bmp', [ARowInfo.RecordIndex + 1])); end; procedure TForm20.FormCreate(Sender: TObject); begin cxGrid1DBTableView1.DataController.ForEachRow(False, DoLoadImageForEachRow); end; end. .dfm object Form20: TForm20 Left = 0 Top = 0 Caption = 'Form20' ClientHeight = 290 ClientWidth = 554 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object cxGrid1: TcxGrid Left = 0 Top = 0 Width = 554 Height = 290 Align = alClient TabOrder = 0 ExplicitLeft = -8 object cxGrid1DBTableView1: TcxGridDBTableView NavigatorButtons.ConfirmDelete = False DataController.DataModeController.SmartRefresh = True DataController.DataSource = DataSource1 DataController.KeyFieldNames = 'RecId' DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> OptionsCustomize.DataRowSizing = True OptionsView.CellAutoHeight = True OptionsView.Indicator = True object cxGrid1DBTableView1RecId: TcxGridDBColumn DataBinding.FieldName = 'RecId' Visible = False end object cxGrid1DBTableView1Field1: TcxGridDBColumn DataBinding.FieldName = 'Field1' Width = 79 end object cxGrid1DBTableView1Column1: TcxGridDBColumn DataBinding.ValueType = 'Variant' PropertiesClassName = 'TcxImageProperties' end end object cxGrid1Level1: TcxGridLevel GridView = cxGrid1DBTableView1 end end object dxMemData1: TdxMemData Active = True Indexes = <> Persistent.Data = { 5665728FC2F5285C8FFE3F010000000A000000010007004669656C6431000103 000000616161010300000062626201030000006363630103000000646464} SortOptions = [] Left = 272 Top = 88 object dxMemData1Field1: TStringField FieldName = 'Field1' Size = 10 end end object DataSource1: TDataSource DataSet = dxMemData1 Left = 272 Top = 120 end end | | Всего записей: 708 | Зарегистр. 13-11-2002 | Отправлено: 15:33 30-08-2011 | Исправлено: vladman, 15:40 30-08-2011 |
|