redwa11
redwa11

Reputation: 15

How to enable/disable a textbox with a button

I looked everywhere for this and didnt find a solution.

All I want is that when I click the button, the textbox becomes enabled, so we can write in it.

I tried :

public void button11_Click(object sender, RoutedEventArgs e)
    {

     textbox11.Enabled = true; 

    }

and this is the xaml code

<TextBox Name="textbox11" IsEnabled="False".....>

but obviously it doesnt work. The error I get :

'System.Windows.Controls.TextBox' does not contain a definition for 'Enabled' and no extension method 'Enabled' accepting a first argument of type 'System.Windows.Controls.TextBox' could be found (are you missing a using directive or an assembly reference?)

Upvotes: 1

Views: 4482

Answers (1)

adv12
adv12

Reputation: 8551

The control doesn't have a property called "Enabled". Try this:

textbox11.IsEnabled = true;

Note the "Is".

Upvotes: 6

Related Questions