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

  • Home
  • SEARCH
  • 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 380597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:00:16+00:00 2026-05-12T15:00:16+00:00

Following code, credit: Guffa. Hello All, I’m trying to add controls to a Form

  • 0

Following code, credit: Guffa.


Hello All,

I’m trying to add controls to a Form at runtime based on the information found in a Plain Text File. The structure? of the text file is always the same, and will not change. Example:

File.txt:

Label
"This is a label"
320, 240

Explanation:

Control
Text
Location

The following code, provided to me by Guffa, doesn’t cause any errors or anything, but at the same time, nothing happens at all. And I’m not sure why… Can somebody please explain why the label doesn’t get created and added to the form with the right info attached to it?

MatchCollection lines = Regex.Matches(File.ReadAllText(fileName), @"(.+?)\r\n""([^""]+)""\r\n(\d+), (\d+)\r\n");
foreach (Match match in lines) {
   string control = match.Groups[1].Value;
   string text = match.Groups[2].Value;
   int x = Int32.Parse(match.Groups[3].Value);
   int y = Int32.Parse(match.Groups[4].Value);
   Console.WriteLine("{0}, \"{1}\", {2}, {3}", control, text, x, y);

   if(control == "Label")
   {
      Label label = new Label();
      label.Text = text;
      canvas.Controls.Add(label); // canvas is a Panel Control.
      label.Location = new Point(x, y);
   }

}

I hope that I have clearly explained my situation. Any help at all would be greatly appreciated.

Thanks for taking the time to read.
jase

  • 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-12T15:00:17+00:00Added an answer on May 12, 2026 at 3:00 pm

    Blind guess: I see the last \r\n in the regex is not optional. Possible that your input file is missing a return character after the last line?

    Additional note about sucking at regular expressions: there are some tools that will help you experiment with regular expressions, which might be useful, for example, to understand what’s going on in this particular case. I always use Expresso, which among other things analyzes the structure of the regular expression you provide and explains what it does.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 239k
  • Answers 239k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've been using it successfully on my blog. I just… May 13, 2026 at 6:56 am
  • Editorial Team
    Editorial Team added an answer The many changes are listed here, starting with the line… May 13, 2026 at 6:56 am
  • Editorial Team
    Editorial Team added an answer You are thinking of a Photomosaic. You can use AndreaMosaic.… May 13, 2026 at 6:56 am

Related Questions

Following code, credit: Guffa. Hello All, I'm trying to add controls to a Form
I am processing credit cards using a payment gateway. To POST the data to
I am trying my hardest to learn jQuery with the Learning Jquery 1.3 Book
Hi I get the following error when I try to validate credit card, it
Following up on this question, I'm working on a large Delphi 7 codebase which

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.