Q:

how to determine which textbox is focused and add text to it...........?

im doing  a complex calculator in  C#.  the first textbox accepts the real part and the second accepts the immaginary part. i wanna be able to use the mouse to enter values also. so if i click button1 it will concat "1" to the value in the textbox on which the focus is on . i cant determine  which textbox is focused. i tried the  stuff some  people posted, like using GotFocus for exemple, and non had worked..
    private Control focusedControl;

    private void TextBox_GotFocus(object sender, EventArgs e)
    {
        focusedControl = (Control)sender;
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (focusedControl != null)
        {
            focusedControl.Focus();
            SendKeys.Send("1"); 

        }

    }

A:

private TextBox focusedControl;

private void TextBox_GotFocus(object sender, EventArgs e)
{
    focusedControl = (TextBox)sender;
}

private void button1_Click(object sender, EventArgs e)
{
    if (focusedControl != null)
    {   

        focusedControl.Text  += "1";
    }

}

You just have to use TextBox_GotFocus as the EventHandler for both textboxes. 

A:

        if ((txtBox as Control).Focused)
        {

        }

