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;

댓글 없음: