Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Display text using labels -- very slow

Display text using labels -- very slow

Scheduled Pinned Locked Moved C#
question
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    printscreen12345
    wrote on last edited by
    #1

    I'm working on a bible project. Part of it is to display bible verses on screen. Given that the bible text are in different formats (some are italics, some are in red, ...). I tried using labels to display them. But if one chapter has 80 verses, I would have to create at least 80 labels. This is very slow - could take 15-20 seconds to display. Apart from using labels, is there any other efficient way to handle text display? Thanks!!

    L R 2 Replies Last reply
    0
    • P printscreen12345

      I'm working on a bible project. Part of it is to display bible verses on screen. Given that the bible text are in different formats (some are italics, some are in red, ...). I tried using labels to display them. But if one chapter has 80 verses, I would have to create at least 80 labels. This is very slow - could take 15-20 seconds to display. Apart from using labels, is there any other efficient way to handle text display? Thanks!!

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Graphics.DrawString() Here is something to get you started:

      class CustomDrawControl : Control
      {
      protected override void OnPaint(PaintEventArgs e)
      {
      e.Graphics.DrawString("blah blah", Font, Brushes.Red, e.ClipRectangle);
      }
      }

      **

      How xacc.ide transforms text to colored words on the screen
      Intel PentuimM (aka Centrino) undervolting

      **

      P 2 Replies Last reply
      0
      • L leppie

        Graphics.DrawString() Here is something to get you started:

        class CustomDrawControl : Control
        {
        protected override void OnPaint(PaintEventArgs e)
        {
        e.Graphics.DrawString("blah blah", Font, Brushes.Red, e.ClipRectangle);
        }
        }

        **

        How xacc.ide transforms text to colored words on the screen
        Intel PentuimM (aka Centrino) undervolting

        **

        P Offline
        P Offline
        printscreen12345
        wrote on last edited by
        #3

        Thanks! Since I'm new to C#, can you be more specific? Do I use graphics instead for each text in those labels I created?

        1 Reply Last reply
        0
        • P printscreen12345

          I'm working on a bible project. Part of it is to display bible verses on screen. Given that the bible text are in different formats (some are italics, some are in red, ...). I tried using labels to display them. But if one chapter has 80 verses, I would have to create at least 80 labels. This is very slow - could take 15-20 seconds to display. Apart from using labels, is there any other efficient way to handle text display? Thanks!!

          R Offline
          R Offline
          Robert Rohde
          wrote on last edited by
          #4

          You could use the RichTextBox[^] control. It supports formatting.

          P 1 Reply Last reply
          0
          • L leppie

            Graphics.DrawString() Here is something to get you started:

            class CustomDrawControl : Control
            {
            protected override void OnPaint(PaintEventArgs e)
            {
            e.Graphics.DrawString("blah blah", Font, Brushes.Red, e.ClipRectangle);
            }
            }

            **

            How xacc.ide transforms text to colored words on the screen
            Intel PentuimM (aka Centrino) undervolting

            **

            P Offline
            P Offline
            printscreen12345
            wrote on last edited by
            #5

            I have taken a look at it. But how can the drawstring be changed? How is the "tabPage1.paint += new System.Windows.Forms.PaintEventHandler(tabPage1_paint)" triggered? -- modified at 3:58 Tuesday 30th May, 2006

            1 Reply Last reply
            0
            • R Robert Rohde

              You could use the RichTextBox[^] control. It supports formatting.

              P Offline
              P Offline
              printscreen12345
              wrote on last edited by
              #6

              But would RichTextBox control be as slow as label control? Someone suggested using paint control. Do you know how to do that?

              D 1 Reply Last reply
              0
              • P printscreen12345

                But would RichTextBox control be as slow as label control? Someone suggested using paint control. Do you know how to do that?

                D Offline
                D Offline
                Dan Neely
                wrote on last edited by
                #7

                The rtb should be much faster than dynamically creating a mess of labels. Paint isn't a control, it's an event for your form. It's more flexible, but if you're a beginner the price in increased effort needed to use is probably not worth it.

                P 1 Reply Last reply
                0
                • D Dan Neely

                  The rtb should be much faster than dynamically creating a mess of labels. Paint isn't a control, it's an event for your form. It's more flexible, but if you're a beginner the price in increased effort needed to use is probably not worth it.

                  P Offline
                  P Offline
                  printscreen12345
                  wrote on last edited by
                  #8

                  I managed to displayed text by using graphic object. g = tabPage1.CreateGraphics(); g.DrawString(text, fnt, brsh, x, y); g.Dispose(); I used labels before and the tabPage was scrollable (tabPage.AutoScroll = true). But now it is not scrollable any more and thus those text at the bottom are missing from the tabPage. Do you know why? -- modified at 11:48 Tuesday 30th May, 2006

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups