Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
C#
using System;
i have a problem with this code the right and left button not working..
at the last part of the code.
could you please help me..

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

namespace CustomerClient
{
    public partial class UsernameKeypad : Form
    {
        public UsernameKeypad()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }
        private void button8_Click(object sender, EventArgs e)
        {
        }
        private void textBoxUsername_TextChanged(object sender, EventArgs e)
        {
              textBox1.SelectionLength = 0;
              textBox1.SelectionStart = textBox1.Text.Length;
              textBox1.Focus();
              textBox1.ScrollToCaret();
         }

        private void button37_Click(object sender, EventArgs e)
        {
            Button cliked = (Button)sender;
            textBox1.Text += cliked.Text;
        }
        private void button29_Click(object sender, EventArgs e)
        {
        }
        private void button12_Click(object sender, EventArgs e)
        {
        }
        private void button13_Click(object sender, EventArgs e)
        {
        }
        private void button14_Click(object sender, EventArgs e)
        {
        }
        private void button15_Click(object sender, EventArgs e)
        {
        }
        private void button16_Click(object sender, EventArgs e)
        {
        }
        private void button17_Click(object sender, EventArgs e)
        {
        }
        private void button18_Click(object sender, EventArgs e)
        {
        }
        private void button19_Click(object sender, EventArgs e)
        {
        }
        private void button20_Click(object sender, EventArgs e)
        {
        }
        private void button21_Click(object sender, EventArgs e)
        {
        }
        private void button22_Click(object sender, EventArgs e)
        {
        }
        private void button23_Click(object sender, EventArgs e)
        {
        }
        private void button24_Click(object sender, EventArgs e)
        {
        }
        private void button25_Click(object sender, EventArgs e)
        {
        }
        private void button26_Click(object sender, EventArgs e)
        {
        }
        private void button27_Click(object sender, EventArgs e)
        {
        }
        private void button28_Click(object sender, EventArgs e)
        {
        }
        private void button30_Click(object sender, EventArgs e)
        {
        }
        private void button31_Click(object sender, EventArgs e)
        {
        }
        private void button32_Click(object sender, EventArgs e)
        {
        }
        private void button33_Click(object sender, EventArgs e)
        {
        }
        private void button34_Click(object sender, EventArgs e)
        {
        }
        private void button35_Click(object sender, EventArgs e)
        {
        }
        private void button36_Click(object sender, EventArgs e)
        {
        }
        private void button7_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Sorry!! Please Input your username.. :) ");
            }
        }
        private void button10_Click(object sender, EventArgs e)
        {
            button37.Text="q";
            button29.Text = "w";
            button12.Text = "e";
            button13.Text = "r";
            button14.Text = "t";
            button15.Text = "y";
            button16.Text = "u";
            button17.Text = "i";
            button18.Text = "o";
            button19.Text = "p";
            button20.Text = "a";
            button21.Text = "s";
            button22.Text = "d";
            button23.Text = "f";
            button24.Text = "g";
            button25.Text = "h";
            button26.Text = "j";
            button27.Text = "k";
            button28.Text = "l";
            button30.Text = "z";
            button31.Text = "x";
            button32.Text = "c";
            button33.Text = "v";
            button34.Text = "b";
            button35.Text = "n";
            button36.Text = "m";
            button2.Visible = true;
            button10.Visible=false;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            button10.Visible = true;
            button2.Visible = false;
            button37.Text = "Q";
            button29.Text = "W";
            button12.Text = "E";
            button13.Text = "R";
            button14.Text = "T";
            button15.Text = "Y";
            button16.Text = "U";
            button17.Text = "I";
            button18.Text = "O";
            button19.Text = "P";
            button20.Text = "A";
            button21.Text = "S";
            button22.Text = "D";
            button23.Text = "F";
            button24.Text = "G";
            button25.Text = "H";
            button26.Text = "J";
            button27.Text = "K";
            button28.Text = "L";
            button30.Text = "Z";
            button31.Text = "X";
            button32.Text = "C";
            button33.Text = "V";
            button34.Text = "B";
            button35.Text = "N";
            button36.Text = "M";
        }
        private void button11_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + " ";
        }
        private void button4_Click(object sender, EventArgs e)
        {
             int textlength = textBox1.Text.Length;
               if (textlength > 0)
                {
                    for (int i = 0; i < textlength;i++ )
                    {
                        textBox1.Text = textBox1.Text.Substring(0, textlength - 1);
                    }
                }
           textBox1.Focus();
        }

        private void leftbtn_Click(object sender, EventArgs e)
        {
            if (textBox1.SelectionStart > 0)
                textBox1.SelectionStart--;
        }
        private void rightbtn_Click(object sender, EventArgs e)
        {
        }
    }
}
Posted

Not working? That is not enough to understand the problem.

Are you getting an error? Trying putting debug points in the code to see if the right / left button clicks execute.
Make sure the click event handlers are attached to this code.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 17-Jul-11 22:52pm    
Right way to address problems, a 5.
--SA
This is not how software is developed. Throw it out and start from scratch. No button should have the name like button_11, no fragment of code should be repeated. No immediate constant like "A", "B" should be used. Ever head of methods with parameters? You are not ready to develop UI, learn methods, method calls, parameters, variables, delegates, events. Start with console applications. Don't come back to more advanced topic until you're able to write code and not what you write right not. Stop wasting your time; what you do is not working.

—SA
 
Share this answer
 
Comments
Abhinav S 17-Jul-11 4:46am    
Just wanted to point you to this. I think you gave me a 1 intead of a 5.

Good answer here though. My 5.
Sergey Alexandrovich Kryukov 17-Jul-11 13:06pm    
Thank you, Abhinav.

Oh, sorry for my mistake; I've fixed it. This is another reason to claim what you vote -- one can see the mistake and point it out.
--SA
Abhinav S 17-Jul-11 13:14pm    
No problem. Thanks that you fixed it.
I was actually -56 points behind because of that vote. :)

Oh then again, what are rep points when the OP is happy with his answer. ;)
Sergey Alexandrovich Kryukov 17-Jul-11 14:00pm    
I never knew my down-vote weights -56 points. Good to know, ha, ha, ha (sinister lough) :-).
--SA
Abhinav S 18-Jul-11 0:33am    
No - see I got you. They weigh only 16 points. 40 was for the up-vote. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900