Recent

Author Topic: Workbook.disableNotifications  (Read 1251 times)

kjteng

  • Sr. Member
  • ****
  • Posts: 259
Workbook.disableNotifications
« on: August 13, 2020, 05:09:53 am »
I am trying to understand the disableNotifications method and its effect on following two sets of codes (code A correctly set the rowcount to 15 but the code B does not set the rowcount correctly). Any help?

Code A:
Quote
  wsGrid1.Workbook.DisableNotifications;
  try
    wsGrid1.rowcount :=15;
  finally
    wsGrid1.Workbook.EnableNotifications;
  end;
  wbSource1.Workbook.ActiveWorksheet.WriteText(5, 1, 'rowcount=15');   

Code B:
Quote
  wsGrid1.Workbook.DisableNotifications;
  try
    wsGrid1.rowcount :=5;
  finally
    wsGrid1.Workbook.EnableNotifications;
  end;
  wbSource1.Workbook.ActiveWorksheet.WriteText(15, 1, 'rowcount=5');   

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Workbook.disableNotifications
« Reply #1 on: August 13, 2020, 10:39:05 am »
If code B you initially set the grid's RowCount to 5, but then you write some text into a cell of worksheet row 15 (i.e. grid row 16). This way the RowCount is automatically expanded to 16

You could remove the option aeData from the WorksheetGrid's AutoExpand property in order to avoid automatic expansion of the RowCount by writing data, but then you'll have an exception because the addressed row does not exist.

 

TinyPortal © 2005-2018