title: Delphi Dbgrid delete a record
body: <p>I have a multiple tabsheet. Each tabsheet in my PageControl that contain an Dbgrid with some button to manipulate this dbgrid.</p>
  
  <p>Sometimes, when i click on button remove, my DBGrid not change. After delete, i see my value in my DBgrid.</p>
  
  <pre><code>If MyTable.recordcount &gt; 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;
  </code></pre>
  
  <p>I try to add </p>
  
  <pre><code> MyTable.Refresh;
  </code></pre>
  
  <p>after delete but it doesn't work.
  The value of myfield in the MessageBox is correct!</p>
  
  <p>This problem appear when i select another Tabsheet in MyDBgrid.
  It can be problem of <strong>focus</strong> in my DBGrid? It can be problem of <strong>state</strong> of my DBGrid(dsBrowser, dsEdit,...)?</p>
  
  <p>=========================================================</p>
  
  <p>I try to create a log for BeforeDelete event and AfterDelete event :</p>
  
  <pre><code>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])); 
  </code></pre>
  
  <p>on AfterDelete event :</p>
  
  <pre><code>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])); 
  </code></pre>
  
  <p>I use the tabsheet as :</p>
  
  <p><a href="http://i.stack.imgur.com/xxApy.png" rel="nofollow">enter image description here</a></p>
  
  <p>I obtain this log</p>
  
  <pre><code>------------------------------------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
  </code></pre>
  
  <p>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 <code>03</code>.</p>