WPREPORTER: Selecting the contents of a group band

  • Hi,

    I want to be able to select all text (including tables) inside a specified group band.

    Here's my code thus far, which works fine unless there's a table immediately at the start of the group, in which case it fails to select anything. In fact, when there are one or more tables inside the group, this code doesn't work very well. Is there a better way to do this?

    Any help would be appreciated!

    Thanks in advance,

    Hedley

    • Offizieller Beitrag

    To select the current group You can use this code:

    Code
    var par : TParagraph;begin par := SourceText.ActivePar.ParentGroup; if par<>nil then begin    SourceText.TextCursor.SelectFromHere( SourceText.ActivePar.ParentGroup, 0 );    SourceText.TextCursor.SelectToHere(par.nextPar, 0);    SourceText.Repaint; end;end;

    Please note that if you need to delete or move the group it will be easier to move that paragraph directly. To duplicate a group you can use thitsd code:

    Code
    var par : TParagraph;
    begin
     par := SourceText.ActivePar.ParentGroup;
     if par<>nil then
     begin
        par.NextPar := par.CreateCopy(par.RTFData,[]);
        SourceText.ReformatAll(false,true);
     end;
    end;

    To delete that group use par.DeleteParagraph;

    Regards,

    Julian Ziersch

  • I have found that the code suggested by wpsupport does not work if you have nested groups, as in this instance, if there is no text between the end of the group and the end of its parent group, the nextPar property returns nil.

    I have found that the following code is more effective for nested groups: