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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:09:12+00:00 2026-06-04T14:09:12+00:00

Hi i am having a problem here. So you can see whenever the txtBtn0

  • 0

Hi i am having a problem here. So you can see whenever the txtBtn0 and txtBtn1 is clicked it increments its own array which is then used for squareChecked string. But what I want to do first is to give out an error message if txtBtn0 nor txtBtn1 is not clicked. But it does not pop up anything.

        public partial class MainForm : Form
{
    public int[] clickNumBoxArray = Enumerable.Repeat(1, 81).ToArray();

    public MainForm()
    {
        InitializeComponent();



     }  ... ... ...



        private void btn1_Click(object sender, EventArgs e) {
         UserSquare checkClickedBox = new UserSquare();

        string checkClickBox = checkClickedBox.squareChecked();
        if (checkClickedBox == null) {
        MessageBox.Show("You did not enter any text on the form");
        }
    }

    private void txtBtn1_Click(object sender, EventArgs e) {
        clickNumBoxArray[1]++;
        if (clickNumBoxArray[1] % 2 == 0) {
            txtBtn1.BackColor = System.Drawing.Color.DarkOrange;
        } else {
            txtBtn1.BackColor = System.Drawing.Color.WhiteSmoke;
        }
    }

    private void txtBtn0_Click(object sender, EventArgs e) {
        clickNumBoxArray[0]++;
        if (clickNumBoxArray[0] % 2 == 0) {
            txtBtn0.BackColor = System.Drawing.Color.DarkOrange;
        } else {
            txtBtn0.BackColor = System.Drawing.Color.WhiteSmoke;
        }
    }

This is the other class

     class UserSquare {
    public string squareChecked() {
        string clickedBoxes = null;
        MainForm numBoxArray = new MainForm();
        int[] clickNumBoxArray = numBoxArray.clickNumBoxArray;
         for (int i = 0; i < 81; i++) {
             if (clickNumBoxArray[i] % 2 == 0) {
                 clickedBoxes += "txtBtn" + i + ", ";
             }
         } return clickedBoxes; 
    }
  • 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-04T14:09:13+00:00Added an answer on June 4, 2026 at 2:09 pm

    About IndexOutOfRange Exception Your problem is that you implement your list here

    public int[] clickNumBoxArray = Enumerable.Repeat(1, 80).ToArray();
    

    as starts from 1 and finished 80 = 80 elements

    but in method your for loop starts from 0 and finished 81 = 81 elements

    and about controlling by error.. simply and tricky.. you can implement an internal / public boolean as default false and set to true in a mouse event as you need (i.e.mouseclick event)..end of your error method or where you need else, set to back false to be ready for another click-event controlling

    About ButtonClick not fire its event (if im not misunderstood) : Did you deleted your some methods of buttons ? could you been forgot to implement it back ?

    open your design mode click once onto your controls which you want to check, and then open properties => events.. if your events implemented then it should be as so : (i.e.)

    (property) MouseClick (value) Button1_MouseClick

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

Sidebar

Related Questions

I'm having a problem here. How you can see on the code below, I
HI Guys, Here I am having problem that How can I post an image
I'm having a problem with pushing an object into an array. Here's my object
Im having a problem here. i downloaded jake wharton. He gave an example of
I'm having a little problem here, I'm new to Actionscript 3, and what I'm
Super weird problem here. I'm having trouble getting jQuery to bind any selectors except
What is the problem here? (Besides having redundant code). $.getJSON works as expected. However
I'm having a hard time trying to create a XmlRepository. The problem here I
I am having a problem with a combo box here. What I did is
I'm having a problem installing SAM 1.1.0 on fedora 16 same as here https://bugs.php.net/bug.php?id=59632&thanks=6

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.