2010년 8월 3일 화요일

cxGridView에서 셀값 가져오기, 저장하기

fr : String;
fr := cxPositionCard.DataController.GetValue(row, column);
현재의 레코드 위치얻기
recno := cxPositionCard.DataController.GetFocusedRecordIndex;

현재라인의 두번째 셀값을 얻으려면
recno := cxPositionCard.DataController.GetFocusedRecordIndex;
fr := cxPositionCard.DataController.GetValue(recno, 1);

또 다른방법

id := cxGridItem.Controller.FocusedRecord.Values[2];
ShowMessage(id);

Values[index:integer] = 그리드의 컬럼 인덱스(0부터 시작함)


var
AFieldFilmCaption, AFieldFilmYear: TField;
AFilmDataSet: TDataSet;

begin
//get TField objects for corresponding columns
AFieldFilmCaption := tvFilmsCaption.DataBinding.Field;
AFieldFilmYear := tvFilmsYEAR.DataBinding.Field;
//get TDataSet owning fields
AFilmDataSet := AFieldFilmCaption.DataSet;
//insert new record
AFilmDataSet.Insert;
//set values for the Caption and Year fields
AFieldFilmCaption.AsString := �Harry Potter and the Sorcerer''s Stone';
AFieldFilmYear.AsInteger := 2001;
//post data
AFilmDataSet.Post;
end;


var
ARecordIndex, AItemIndex: Integer;
//...
try
AItemIndex := 0;
for ARecordIndex := 0 to tvCustomers.DataController.RecordCount - 1 do
tvCustomers.DataController.Values[ARecordIndex, AItemIndex] := ARecordIndex;
except
on E: Exception do
ShowMessage('Cannot set a value due to the exception: ' + E.Message);
end;

ExpressScheduler설치방법

1) Run the Express Install and select the products you want to install. Deactivate the "Create product libraries" for Delphi 2007 in the Customization screen of the installer ... just because this option is useless.
2) The Express Install will put the source files and packages of our components to the specified folder on the disk. You must compile the libraries in the following order (as they are called in the Express Install folders):
NOTE 1: If you don’t own a specific product and the corresponding libraries are missing, simply skip them in this list.
NOTE 2: We haven't ported our older products (like the ExpressInspector, ExpressQuantumTreeList v3, ExpressQuantumGrid v3, etc.) to Delphi 2007 because we support new IDEs only for "active" products.
XP Theme Manager
ExpressGDI+ Library
ExpressLibrary
ExpressCommon Library
ExpressExport Library
ExpressNavBar
ExpressMemData
ExpressDBTree Suite
ExpressMasterView
ExpressSpreadSheet
ExpressFlowChart
ExpressOrgChart
ExpressPageControl 2
ExpressDataController
ExpressEditors Library 5
ExpressScheduler 2
ExpressPivotGrid
ExpressVerticalGrid
ExpressQuantumTreeList 4
ExpressQuantumGrid 6
ExpressBars 6
ExpressSideBar
ExpressDocking Library
ExpressLayout Control
ExpressPrinting System
ExpressSkins Library
3) Put all the necessary files into a single folder to simplify the compilation process. In particular, take the files from the Sources and Packages directory of each library. Packages for Delphi 2007 are named with the D11 suffix.
4) Compile the runtime packages first, then their design-time counterparts (with the dcl~ prefix in their names).
NOTE: To automate compilation, I recommend that you include all the packages into a single project group. When rebuilding the group, the compiler should recognize the dependent packages and determine which packages to compile first.
5) Install the compiled design-time packages.
Hopefully, this will help you install our components. Please keep us informed of your progress.

ExpressQuantumGrid에서 드래그 앤 드롭

cxGrid에서 cxGrid로 드래그 앤 드롭을 구현하기

드래그할 그리드와 드롭할 그리드에 모드 드래그 모드를 Auto로 설정한다.

드래그하는 그리드의 현재데이터를 가져오기위해서 다음의 스크립트 작성
procedure TForm1.cxGridItemStartDrag(Sender: TObject;
var DragObject: TDragObject);
begin
DragContentID := udsContents.DataSet.FieldByName('rno').AsInteger;
end;
위에서 DragContentID는 전역변수로 데이터셋에서 드래그하는 데이터의 일련번호를 변수에 저장한다.


드래그를 드롭하는 그리드의 다음 속성을 추가한다.
Accept속성을 트루로 하여 드래그드롭을 받아들이도록 한다.

procedure TForm1.gridKind2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
var
id : integer;
begin
Accept := (Source is TcxDragControlObject);
end;

드롭할 그리드에 다음의 속성을 추가한다.

procedure TForm1.gridKind2DragDrop(Sender, Source: TObject; X, Y: Integer);
var
id : integer;
begin
id := udsKind2.DataSet.FieldByName('rno').AsInteger;
Label1.Caption := IntToStr(DragContentID);
with qryContentUpdate do begin
SQL.Clear;
SQL.Add('update scriptdata set kind2 = :nid ');
SQL.Add(' where rno = :orno ');
ParamByName('nid').Value := id;
ParamByName('orno').Value := DragContentID;
Execute;
end;
udsContents.DataSet.Refresh;
// ShowMessage(IntToStr(DragContentID));
end;
드롭하는 소스의 아이디(전역변수:DragcontentID)와 드롭한 그리드의 rno로 자료를 수정하는 sql문을 작성한다.
qryContentUpdate 는 uniQuery콘트롤을 폼에 올려만 놓으면 된다. 연결을 컴포넌트에서 지정한다.