设置了GridMode=True,遍历多选记录时,总是提示内存异常错误,大家帮帮忙呀!!!
解决方案 »
- 请教:有个*.log的文件中特殊字符的替换问题!请高手指教!(解决后马上给分!多谢了!)
- 显示图像的简单问题,如何让他按y轴显示数据(up有分)应该不太难,怎么没人领分呢?可是问了很久都没人能做出来?郁闷
- 如何招聘一个德才兼备的程序员,请用经验兄弟支招!百分相赠!
- 我能连接上,为什么打不开里面的文件?
- 请教:你们都是专职程序员吗?
- 请问高手,怎样锁定一个文件?
- 我想问一下C/S结构的程序.
- AfterOpen事件怎么写???
- 高分请教:如何在DELPHI 将金额数据传送到顾客显示屏上?
- 怎样将QuickRep报表的内容导出到WORD中(报表中带有表格)?
- 有谁谁知道在那里开启dbxdrivers.ini这个dbExpress驱动程序模板文件啊? 在线等
- N久不来CSDN, 今日一上就看到阿日要辞去大版, 心与嘴里的雪糕样洼凉、洼凉的.
即使不用GridMode也可以,只要是能提高速度又可以用多选功能就可以。我没有解决办法了。
那么打开数据集之后grid自身要遍历一遍数据
你把遍历的代码帖出来看看
4568行改为:Result := TcxCustomGridRecord(FRecords[abs(Index)]);
cxDBData.pas
1867行:回车换行,然后增加:
begin
if not DataSet.Active then Exit; ......
......
end;
2005-12-15:
cxDBData.pas 1908行 procedure TcxDBDataProvider.MoveBy(ADistance: Integer);
begin
if Assigned(DataSet) then
DataSet.MoveBy(ADistance);
end;
改为:
procedure TcxDBDataProvider.MoveBy(ADistance: Integer);
begin
if Assigned(DataSet) then
begin
if DataSet.State in [dsInsert, dsEdit] then
DataSet.Cancel;
DataSet.MoveBy(ADistance);
end;
end;cxGridCustomTableView.pas 8935行,回车,粘贴 DataController.Cancel;
这样的话,对cxGrid的其他功能有没有影响呀~~
用行数的话有些不明确呀,我的行数和你的行数好像不太一样。改完了我编译就出现错误了,都是内存地址错误。
把选中的记录中的一个字段添加到Memo1中。这样运行就会有错误了procedure TForm1.Button1Click(Sender: TObject);
var
iRowCount, i, n: Integer;
begin
iRowCount := cxGrid1DBTableView1.Controller.SelectedRecordCount;
showmessage(IntToStr(iRowCount));
for i:=0 to iRowCount-1 do
begin
n := cxGrid1DBTableView1.Controller.SelectedRows[i].RecordIndex;
inc(n);
Memo1.Lines.Add(IntToStr(cxGrid1DBTableView1.Controller.SelectedRecords[i].Values[0]));
end;
end;
遍历选中的记录我是这么做的:
for i:=0 to cxGridDBTableView2.DataController.RecordCount - 1 do
begin
if cxGridDBTableView2.DataController.IsRowSelected(i) then
begin
sessionid := vartostrdef(cxGridDBTableView2.DataController.GetValue(i, 0), '');
...
end;
end;
4568行
function TcxCustomGridTableViewData.GetInternalRecord(Index: Integer): TcxCustomGridRecord;
begin
Result := TcxCustomGridRecord(FRecords[abs(Index)]);///////
end;
cxDBData.pas
1867行:
procedure TcxDBDataProvider.First;
var
AReopened: Boolean;
begin
FInFirst := True;
try
inherited First;
if Assigned(DataSet) then
begin
if not DataSet.Active then Exit;///////
with DataController do
begin
....
2005-12-15:
cxDBData.pas 1908行
procedure TcxDBDataProvider.MoveBy(ADistance: Integer);
begin
if Assigned(DataSet) then
begin
if DataSet.State in [dsInsert, dsEdit] then/////
DataSet.Cancel;/////
DataSet.MoveBy(ADistance);
end;
end;cxGridCustomTableView.pas 8935行
function TcxCustomGridTableController.FocusNextRecord(AFocusedRecordIndex: Integer;
AGoForward, AGoOnCycle, AGoIntoOutDetail: Boolean): Boolean;
var
AGridView: TcxCustomGridTableView;
APrevFocused, ACycleChanged: Boolean;
APrevFocusedRecord, ANextRecord, AChildRecord: TcxCustomGridRecord;
ANextRecordIndex: Integer; procedure CheckEditing;
var
AGridView: TcxCustomGridTableView;
begin
AGridView := GridView;
//AGridView.BeginUpdate; - commented because of dialog calling in OnBeforePost
AGridView.AddListenerLink(@AGridView);
try
if DataController.IsEditing then
begin
EditingController.UpdateValue;
DataController.Cancel;//////////////////
if not (dceModified in DataController.EditState) then
begin
...
您的遍历方式查到的是这个窗口中的数据的。对超过了窗口记录范围外的数据就遍历不到了。
cxGridDBTableView2.DataController.RecordCount 显示的并不是数据集的全部记录数。
ColIdx := View.DataController.GetItemByFieldName(AFieldName).Index;
OutputVal := View.DataController.Values[RecIdx, ColIdx]; //RecID := View.DataController.GetRecordId(RecIdx);
//OutputVal := ADataSet.Lookup(View.DataController.KeyFieldNames, RecID, AFieldName);2) View.DataController.DataModeController.GridMode = True时
Bkm := View.DataController.GetSelectedBook(ASelectedRecordIndex);
if ADataSet.BookValid(TBook(Bkm)) then
begin
ADataSet.Book := TBook(Bkm);
OutputVal := ADataSet.FieldByName(AFieldName).Value;
end; View.BeginUpdate;
View.DataController.BeginLocate;
try
// make changes here…
finally
View.DataController.EndLocate;
View.EndUpdate;
end;=============================================================