Nevron Open Vision Documentation
Rich Text Editor / Document Model / Blocks / Block Size
In This Topic
    Block Size
    In This Topic

    Each block in Nevron Rich Text has several properties that allow you to control the block size as well as to specify minimum and maximum size preferences.

     Block Width

    The width of a block is controlled from the PreferredWidth, MinWidth, and MaxWidth properties. Those properties can be specified either as fixed units (dips) or as percentages of the parent block content width. The following code example shows how to create a paragraph that spans 50% of the parent block width, but is always wider than 50 dips and narrower than 250dips:

    Setting Block Width Preferences
    Copy Code
    NParagraph paragraph = new NParagraph("Paragraph with Preferred Width 50%, Min Width 50 dips, Max Width 250 dips");
    
    paragraph.BackgroundFill = new NColorFill(NColor.LightGray);
    paragraph.PreferredWidth = new NMultiLength(ENMultiWidthUnit.Percentage, 50);
    paragraph.MinWidth = new NMultiLength(ENMultiWidthUnit.Dip, 50);
    paragraph.MaxWidth = new NMultiLength(ENMultiWidthUnit.Dip, 250);
    
    section.Blocks.Add(paragraph);
    

    If you do not specify a preferred width each block will automatically compute a width, depending on the block type. Paragraphs and Group Blocks use 100% of the container block content width. Tables will be sized so that the used width is enough to accomodate the cell content in the table.

    In certain cases, you may want the automatically computed width of a block to be the width of the block without any hard line breaks (a hard line break is a break that is introduced to a paragraph in order to fit the parent width without having lines that extend outside the parent block). This is useful when you want to emulate the behaviour of <pre> tags in html. To do this you can set the WrapDesiredWidth and WrapMinWidth properties to false:

    Setting Block Width Preferences
    Copy Code
    NParagraph paragraph = new NParagraph("Paragraph with disabled line folding.");
    
    paragraph.WrapDesiredWidth = false;
    paragraph.WrapMinWidth = false;
    
    section.Blocks.Add(paragraph);
    

    The WrapDesiredWidrth/WrapMinWidth properties can be applied on any block. When applied on the root block in Web layout mode the control will not introduce hard breaks - this feature can be very useful if you want to create a code editor or a Notepad alternative for example.

     Block Height

    Similarly to block width the block height is controlled from the PreferredHeight, MinHeight, and MaxHeight properties. Those properties can be specified either as fixed units (dips) or as percentages of the first ancestor block with fixed height. The following code example creates a paragraph that spans 50% of the first ancestor block with a fixed height taller than 100 dips and shorter than 250dips:

    Setting Block Height Preferences
    Copy Code
    NParagraph paragraph = new NParagraph("Paragraph with Preferred Height 50%, Min Height 100 dips, Max Height 250 dips");
    
    paragraph.BackgroundFill = new NColorFill(NColor.LightGray);
    
    paragraph.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Percentage, 50);
    paragraph.MinHeight = new NMultiLength(ENMultiLengthUnit.Dip, 100);
    paragraph.MaxHeight = new NMultiLength(ENMultiLengthUnit.Dip, 250);
    
    section.Blocks.Add(paragraph);
    
    In the absence of an ancestor block with fixed preferred height (PreferredHeight specified in dips) the block will use the document root window area height in web / normal layout or the containing section page content area height in Print layout.
    See Also