trichview.com

trichview.support




Re: Selected Cells


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/05/2004 15:14:26


Parameters of GetEditedCell are output parameters.


if table.GetEditedCell(r,c)<>nil then

  EditedCell := table.Cells[r,c]

else

  EditedCell := nil;


for r := 0 to table.Rows.Count-1 do

  for c := 0 to table.Rows[r].Count-1 do

    if (table.Cells[r,c]<>nil) and

       ((table.IsCellSelected(r,c)) or (table.Cells[r,c]=EditedCell)) then

      table.Cells[r,c].BestWidth:=10


PS: if you want to make this operation undoable, use SetCellBestWidth

instead of BestWidth



ar item: TCustomRVItemInfo;

    table: TRVTableItemInfo;

    Data: Integer;

    rve: TCustomRichViewEdit;

    ItemNo: Integer;

begin


if not RichViewEdit1.CanChange or

   not RichViewEdit1.GetCurrentItemEx(TRVTableItemInfo, rve, item) then

  exit;

table := TRVTableItemInfo(item);

ItemNo := rve.GetItemNo(table);


rve.BeginUndoGroup(rvutModifyItem);

rve.SetUndoGroupMode(True);

rve.BeginItemModify(ItemNo, Data)

if table.GetEditedCell(r,c)<>nil then

  EditedCell := table.Cells[r,c]

else

  EditedCell := nil;


for r := 0 to table.Rows.Count-1 do

  for c := 0 to table.Rows[r].Count-1 do

    if (table.Cells[r,c]<>nil) and

       ((table.IsCellSelected(r,c)) or (table.Cells[r,c]=EditedCell)) then

      table.SetCellBestWidth(10, r, c);


rve.SetUndoGroupMode(False);

rve.EndItemModify(ItemNo, Data)

rve.Change;


> I have added the code table.GetEditedCell(r,c)<>nil to make posible

> changing not only selected cells but also one cell. But I have noticed

> that sometimes there appears an error: List index out of bounds.

>

> I do not understand what's wrong. Why?

>

>

>   for r := 0 to table.Rows.Count-1 do

>   for c := 0 to table.Rows[r].Count-1 do

>     if ((table.Cells[r,c]<>nil) and ((table.IsCellSelected(r,c)) or

> (table.GetEditedCell(r,c)<>nil))) then

>         table.Cells[r,c].BestWidth:=10

>

>

> "Sergey Tkachenko" <[email protected]> wrote in message

> news:[email protected]...

> > for r := 0 to table.Rows.Count-1 do

> >   for c := 0 to table.Rows[r].Count-1 do

> >     if (table.Cells[r,c]<>nil) and

> >        table.IsCellSelected(r,c) then ...

> >

> >

>

>





Powered by ABC Amber Outlook Express Converter