I have a multiple tabsheet. Each tabsheet in my PageControl that contain an Dbgrid with some button to manipulate this dbgrid.
Sometimes, when i click on button remove, my DBGrid not change. After delete, i see my value in my DBgrid.
If MyTable.recordcount > 0 then
begin
str := 'Value of name field/**' + MyTable.FieldByName('Name').AsString+'**/';
If Application.MessageBox(PChar(str), PChar('NAME'), MB_OKCANCEL + MB_ICONQUESTION) = IDOK then
begin
MyTable.Delete;
end;
end;
I try to add
MyTable.Refresh;
after delete but it doesn't work. The value of myfield in the MessageBox is correct!
This problem appear when i select another Tabsheet in MyDBgrid. It can be problem of focus in my DBGrid? It can be problem of state of my DBGrid(dsBrowser, dsEdit,...)?
=========================================================
I try to create a log for BeforeDelete event and AfterDelete event :
Log(1,'------------------------------------Before Del');
Log(1,Format('DataSet.IsEmpty:%s',[BoolToStr1(DataSet.IsEmpty)]));
Log(1,Format('DataSet.State:%d',[Ord(DataSet.State)]));
Log(1,'--------');
Log(1,Format('DataSet.RecNo:%d',[DataSet.RecNo]));
Log(1,Format('DataSet.TabSheet:%s',[DataSet.FieldByName('TabSheetName').AsString]));
Log(1,Format('DataSet.FieldName:%s',[DataSet.FieldByName('FieldName').AsString]));
Log(1,Format('DataSet.FieldId:%s',[DataSet.FieldByName('FieldId').AsString]));
on AfterDelete event :
Log(1,'------------------------------------After Del');
Log(1,Format('DataSet.IsEmpty:%s',[BoolToStr1(DataSet.IsEmpty)]));
Log(1,Format('DataSet.State:%d',[Ord(DataSet.State)]));
Log(1,'--------');
Log(1,Format('DataSet.RecNo:%d',[DataSet.RecNo]));
Log(1,Format('DataSet.TabSheet:%s',[DataSet.FieldByName('TabSheetName').AsString]));
Log(1,Format('DataSet.FieldName:%s',[DataSet.FieldByName('FieldName').AsString]));
Log(1,Format('DataSet.FieldId:%s',[DataSet.FieldByName('FieldId').AsString]));
I use the tabsheet as :
enter image description here
I obtain this log
------------------------------------Before Del
DataSet.IsEmpty:False
DataSet.State:1
--------
DataSet.RecNo:7
DataSet.TabSheet:tabsheet_0
DataSet.FieldName:
DataSet.FieldId:03
------------------------------------After Del
DataSet.IsEmpty:False
DataSet.State:1
--------
DataSet.RecNo:6
DataSet.TabSheet:tabsheet_0
DataSet.FieldName:
DataSet.FieldId:03
You can see in my log: the dataset not change (filedname and fieldId not change / the RecNo properties is change ) after delete the row that contain 03
.