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 8275885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:12:40+00:00 2026-06-08T08:12:40+00:00

I am creating a tool in Visual C#.Net. The algorithm of the tool is

  • 0

I am creating a tool in Visual C#.Net. The algorithm of the tool is to check for all space/s before/after a parenthesis and create an error message for the found errors.
For example: input is ( Text )
Error will be raise because space before and after the parenthesis is detected.
If errors are found the code will add the errors in listview1.items().

To make my question much clearer for you here’s my code:

private void button1_Click(object sender, EventArgs e)
        {
            int error_counter = 0;
            listView1.Items.Clear();

            //requirement 8c
            //check for a space in open and close parenthesis
            Regex test = new Regex(@"\(\s.+\s\)|\[\s.+\s\]|\{\s.+\s\}", RegexOptions.IgnoreCase);
            MatchCollection matchlist = test.Matches(richTextbox1.Text);
            if (matchlist.Count > 0)
            {
                for (int i = 0; i < matchlist.Count; i++)
                {
                    Match firstMatch = matchlist[i];
                    string firstMatch_string = firstMatch.ToString();
                    string[] errors = new string[matchlist.Count];
                    errors[i] = "Ommit Space between a bracket";
                    listView1.Items.Add(errors[i]);
                    error_counter++;
                }
            }
        }

        private void listView1_ItemActivate(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem item = listView1.SelectedItems[0];
                MessageBox.Show(item.ToString());
            }
        }

What I looking for is that all of the items of my listview1 will be clickable, and after a click was made by the user the tool will highlight the error found in the richtextbox1.

Thanks for all your help guys!

  • 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-06-08T08:12:42+00:00Added an answer on June 8, 2026 at 8:12 am

    As someone already told you, use the Index and Length properties of the Match class. Here’s a short example implementing a weird textbox selection strategy. But it works effectively demonstrating the concept:

    public partial class Form1 : Form
    {
        List<Error> errors = new List<Error>();
    
        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            errors = new List<Error>();
            listView1.Items.Clear();                                    
            foreach(Match m in Regex.Matches(richTextBox1.Text, @"(\(\s+|\s+\)|\[\s+|\s+\]|\{\s+|\s+\})", RegexOptions.IgnoreCase))
            {                           
                //you may decide to differentiate the msg according to the specific problem
                Error error = new Error(m, "Ommit Space between a bracket");
                this.errors.Add(error);
                listView1.Items.Add(error.msg);                
            }            
        }
    
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                Error error = errors[listView1.SelectedIndices[0]];
                Select(richTextBox1, error);
            }
        }
    
        private static void Select(RichTextBox rtb, Error e) {
            string o = rtb.Text;
            rtb.Clear();
            for (int i = 0; i < o.Length; i++)
            {
                if (i >= e.index && i <= e.index + e.length)
                {
                    rtb.SelectionColor = Color.White;
                    rtb.SelectionBackColor = Color.Red;
                }
                else
                {
                    rtb.SelectionColor = Color.Black;
                    rtb.SelectionBackColor = Color.White;
                }
                rtb.AppendText(o[i].ToString());
            }
        }              
    }
    
    public class Error
    {
    
        public int index;
        public int length;
        public string value;
        public string msg;
    
        public Error(Match m, string msg)
        {
            this.index = m.Index;
            this.length = m.Length;
            this.value = m.Value;
            this.msg = msg;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have referred this for creating error message tool tips, to be displayed continuously
I'm looking for a free and simple tool for creating relational model diagrams. All
I have a T4 that is generating multiple .html files. After creating them all
I'm creating my first program in Visual Studio C++ 2008, coming from VB.NET -
Visual Studio 2010 MSSQL 2005 Windows Vista I am creating an ASP.NET website using
I'm creating a tool that works with file strings and I need to get
I am creating a tool with which to edit web pages within a CMS.
Is there some kind of tool for creating user interfaces using ATL for C/C++?
I used wsimport command line tool for creating classses but I want to do
Does anybody know of a reliable, well-made tool for creating standalone desktop applications complete

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.