C# - Menu Strip Duplicating for no Apparent Reason

I'm creating a Windows form based multi tap (old phone keypad) type system, using timers and arrays. However, whenever I click a button to append text to a text box, the menu strips duplicates vertically, I have no idea why seem as I have note referenced the menu string in my CS. The code itself isn't finished, I'd just like to stop this duplication from happening, and for the character from the array to actually append to the Rich Text Box. Any help at all would be appreciated, thanks!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

    namespace Mini_Keyboard
    {
        public partial class MiniKeyboard : Form
        {
            public MiniKeyboard()
            {
                InitializeComponent();
            }

            string currentMode = "Multi Tap"; // Sets the mode of the app on startup to be "Multi Tap"
            int intIntervalRequired = 1000; // Time interval in which the user has to switch through the characters
            string currentKey;
            string prevKey;
            int currentIndex = -1;
            string[] keyPad1 = new string[7] { ".", "~", "\"", "1", "'", ":", ";" }; // Characters for key 1
            string[] keyPad2 = new string[7] { "a", "b", "c", "2", "A", "B", "C" }; // Characters for key 2
            string[] keyPad3 = new string[7] { "d", "e", "f", "3", "D", "E", "F" }; // Characters for key 3
            string[] keyPad4 = new string[7] { "g", "h", "i", "4", "G", "H", "I;" }; // Characters for key 4
            string[] keyPad5 = new string[7] { "j", "k", "l", "5", "J", "K", "L" }; // Characters for key 5
            string[] keyPad6 = new string[7] { "m", "n", "o", "6", "M", "N", "O" }; // Characters for key 6
            string[] keyPad7 = new string[9] { "p", "q", "r", "s", "7", "P", "Q", "R", "S" }; // Characters for key 7
            string[] keyPad8 = new string[7] { "t", "u", "v", "8", "T", "U", "V" }; // Characters for key 8
            string[] keyPad9 = new string[9] { "w", "x", "y", "z", "9", "W", "X", "Y", "Z" }; // Characters for key 9
            string[] keyPad0 = new string[2] { "0", " " }; // Characters for key 0
            string[] keyPadStar = new string[3] { "*", "-", "_" }; // Characters for key Star
            string[] keyPadHash = new string[3] { "#", "-", "_" }; // Characters for key Hash
            Timer timer = new Timer();
            public void runTimer()
            {
                InitializeComponent();

                timer.Tick += new EventHandler(stopTimer);
                timer.Interval = intIntervalRequired;
                timer.Enabled = true;
                timer.Start();
            }

            public void stopTimer(object sender, EventArgs e)
            {
                timer.Stop();
                prevKey = currentKey;
                currentKey = "";
                currentIndex = -1;
            }

            private void btnChangeMode_Click(object sender, EventArgs e)
            {
                if (currentMode == "Multi Tap") // If the current mode is "Multi Tap", change it to "Prediction"
                {
                    currentMode = "Prediction";
                    txtCurrentMode.Text = currentMode;
                }
                else // If the current mode is "Prediction", change it to "Multi Tap"
                {
                    currentMode = "Multi Tap";
                    txtCurrentMode.Text = currentMode;
                }
            }

            private void btnKeyPadNo2_Click(object sender, EventArgs e)
            {
                currentKey = "2";
                appendChar(ref keyPad2);
            }

            public void appendChar(ref string[] key)
            {
                runTimer();
                if (currentIndex == -1)
                {
                    currentIndex++;
                    rtbCurrentString.AppendText(key[currentIndex]);
                }
            }
        }
    }

This is a recode of a form I made before which had the same bug, I decided to start from scratch to fix it, but it didn't.

Here's a link to a screencap of the problem:

UPDATE: Turns out the Mode button is no longer working, and it was fine before this happened.

Answers


Remove the InitializeComponent(); in runTimer. It should be called once in constructor.

Your current flow is:

appendChar -> runTimer -> InitializeComponent


Need Your Help

WP7 Deeplink to Marketplace

windows-phone-7 deep-linking marketplace

Does anyone know what code to use specifically to jump from within a Windows Phone 7 application to the application's listing in the Marketplace?

Live Wallpaper Preview Thumbnail Size

android live-wallpaper

What's the width and height of the live wallpaper preview thumbnail in pixels? It's definitely larger than 72x72, that I know.

How to pull image out of container with position absolute but keep in document flow?

html css

I have a content container that is 500px wide and floated to the right. This container contains text and then an image and then some more text. Ultimately I would like to pull this image out of the