Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7518459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:45:13+00:00 2026-05-30T01:45:13+00:00

OK in my notepad like program, I want to print the text like code

  • 0

OK in my notepad like program, I want to print the text like code so I want the reserved words to be printed in blue and the text to be within the margins any ideas how to do this??
This is what i have so far.

    int charPag = 0;
        int linPag = 0;
        Font rodFont = new Font("Courier New", (float)10.0);

        e.Graphics.MeasureString(stringToPrint, txtMain.Font, e.MarginBounds.Size, StringFormat.GenericTypographic, out charPag, out linPag);
        e.Graphics.DrawString(stringToPrint, txtMain.Font, new SolidBrush(Color.Black), e.MarginBounds, StringFormat.GenericTypographic);
        stringToPrint = stringToPrint.Substring(charPag);

        e.Graphics.DrawLine(Pens.Black, e.MarginBounds.Left, e.MarginBounds.Bottom, e.MarginBounds.Right, e.MarginBounds.Bottom);
        e.Graphics.DrawString(numPag.ToString(), rodFont, Brushes.Black, e.MarginBounds.Right - (numPag.ToString().Length * rodFont.SizeInPoints), e.MarginBounds.Bottom + 5);
        if (stringToPrint.Length > 0)
        {
            e.HasMorePages = true;
            numPag++;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:45:13+00:00Added an answer on May 30, 2026 at 1:45 am

    Create a HashSet holding the reserved words

    public HashSet<string> _reservedWords = 
        new HashSet { "if", "else", "class", "..." };
    

    Then you will have to find the identifiers contained in a text line. Identifiers are character sequences beginning with a letter or an underscore and consisting of letters, underscores and digits.

    Once you have found an identifier, check whether it is a reserved keyword or not

    bool reserved = _reservedWords.Contains(word);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a notepad-like program. To get the text from a file I read
How would I open a program within Visual Basic 2010? (Like running Application.txt from
I am looking for a type of text file like notepad .txt, but one
The program’s code is like below: using System.Diagnostics; class Test { static void Main()
I need to create a window for showing text in multiple line(like notepad.below is
I want to build an notepad-style application on android that will have syntax highlighting.
What are cons to write and manage CSS in notepad? in compare to any
I open up a notepad from my program using Process.Start() but the new opened
I would like to know how to write up the vbs code to schedule
I have a Java program which generates a text file on a UNIX server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.