---
title: "Draw Lists"
canonical: https://www.graphicsmill.com/samples/Text/FormattedText/DrawLists_cs
product: "Graphics Mill"
source: "Text/FormattedText/DrawLists.cs"
---

# Draw Lists

Draws formatted text with ordered and unordered lists.

## Instruction

This code demonstrates how to draw various types of ordered and unordered lists (including nested lists) on a bitmap using the GraphicsMill library.
It shows different types of list item markers (numbers, lowercase letters, uppercase letters, roman numerals, and custom bullet types).

## Usings

```csharp
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
using (var bitmap = new Bitmap(600, 600, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetGraphics())
{
    // Ordered list (number)
    {
        var dummyText =
            @"<ol>" + // <ol style='type:numbers;'>
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(20f, 20f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (lowercase letters)
    {
        var dummyText =
            @"<ol style='type:lowerLetter;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(220f, 20f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (uppercase letter)
    {
        var dummyText =
            @"<ol style='type:upperLetter;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(420f, 20f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (lowercase roman numerals)
    {
        var dummyText =
            @"<ol style='type:lowerRoman;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(20f, 220f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (uppercase roman numerals)
    {
        var dummyText =
            @"<ol style='type:upperRoman;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(220f, 220f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Ordered list (start from 10)
    {
        var dummyText =
            @"<ol style='start:10;'>" +
                @"<li>Tenth</li>" +
                @"<li>Eleventh</li>" +
                @"<li>Twelfth</li>" +
                @"<li>Thirteenth</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(420f, 220f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Unordered list (circle)
    {
        var dummyText =
            @"<ul style='type: #9675;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ul>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Arial", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(20f, 420f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Unordered list (square)
    {
        var dummyText =
            @"<ul style='type: #9632;'>" +
                @"<li>First</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
                @"<li>Fourth</li>" +
            @"</ul>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Arial", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(220f, 420f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

    // Nested lists
    {
        var dummyText =
            @"<ol>" +
                @"<li>First" +
                    @"<ul style='type: #9679;'>" +
                        @"<li>First</li>" +
                        @"<li>Second</li>" +
                        @"<li>Third</li>" +
                        @"<li>Fourth</li>" +
                    @"</ul>" +
                @"</li>" +
                @"<li>Second</li>" +
                @"<li>Third</li>" +
            @"</ol>";

        var boundedText = new BoundedText(dummyText, graphics.CreateFont("Arial", 18f), new SolidBrush(RgbColor.Black))
        {
            Rectangle = new System.Drawing.RectangleF(420f, 420f, 160f, 160f),
        };

        graphics.DrawText(boundedText);

        graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
    }

bitmap.Save("DrawLists.png");
```

## Explanation

The code:

- Creates a 600x600 pixel bitmap with a white background.
- Defines and draws several types of ordered lists (ol) and unordered lists (ul) using different markers:
- Ordered lists with numbers, lowercase letters, uppercase letters, lowercase roman numerals, uppercase roman numerals, and custom start values.
- Unordered lists with circle and square bullet types.
- Nested ordered and unordered lists, showcasing how to handle list hierarchy.
- Each list is drawn inside a bounded area on the bitmap, and a red rectangle is drawn around each list for clarity.
- The final result is saved to "DrawLists.png".

## Tags

- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text
- [Formatted Text](<https://www.graphicsmill.com/samples/tags/formatted-text_md>): XML-based formatted text syntax

## Output

- [DrawLists.png](<https://www.graphicsmill.com/samples/Text/compiled/Debug/DrawLists_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.BoundedText](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_BoundedText.htm.md>)
- [Aurigma.GraphicsMill.Drawing.BoundedText.Rectangle](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_BoundedText_Rectangle.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.CreateFont(String,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_CreateFont_2_1dbfa9fa.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawRectangle(Pen,RectangleF)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawRectangle_2_169e24a7.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawText(Text)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawText_1_f576d03f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Pen](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Pen.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
