Similar Posts

Subscribe
Notify of
7 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Yunnik
1 year ago

At Click, a function comes into the code prevent where you write what happens when you click on the button, e.g. that the value from the text box is stored in a variable

Textchanged also creates a function in which the code jumps every time what changes in the text box, for example, I checked whether only numbers or letters were written

FaTech
1 year ago
Reply to  Yunnik

This is WinForms and WinForms has no XAML. WPF would be XAML. But WinForms can be seen in the picture.

Yunnik
1 year ago
Reply to  FaTech

Oh, I didn’t care

FaTech
1 year ago

You use Visual Studio (probably) 2022. Your GUI Framework is WinForms (Windows Forms). Recognizable on the screenshot.

Where I demanded, the screenshot was not there. Maybe you’ve done it or it’s been banished.

What you’re looking for is the ToolBox. There you will find 2 elements. A text box and a RichTextBox. If the ToolBox is not there, then on: View (View) > Toolbox (maybe different in the German version).

Insert then by drag & drop

FaTech
1 year ago
Reply to  DANIELdjldqwj

Close designer and double-click to re-open (Don’t close Visual Studio, just the designer (the tab where design stands). This might help

Charmin
1 year ago

Since Visual Studio 2022 can be used for many different programming languages and project types, I will give the guidance for a C# Windows form project. The steps can vary according to project type.

Steps to add a text box in a C# Windows Forms project:

  1. Open or create project: Start Visual Studio 2022 and open an existing Windows Forms project or create a new one.
  2. Select form: Once your project is open, navigate to the Windows Forms designer by double-clicking the form (usually Form1.cs) in the “Solution Explorer” window.
  3. Open Toolbox window: If the Toolbox is not already open, you can open it by going to view -> Toolbox or simply pressing Strg+Alt+X.
  4. Find Textbox: In the Toolbox you will find a category called “General Controls” or simply “Common Controls”. Under this category you will find the “TextBox” control element.
  5. Add textbox: drag the “TextBox” control element from the toolbox into the form or click “TextBox” in the toolbox and then click the place in the form where the textbox is to appear.
  6. Change properties: As soon as the text box is in the form, you can change their properties like size, position and others in the Properties window.
  7. Add code: To add program logic, such as what happens when the user enters text, you can add an event handler in your C# code. You do that by double clicking on the text box in the designer. Visual Studio then automatically generates an event handler method for you.

That’s it! You have successfully added a text box to your Windows Forms project in Visual Studio 2022. If you have more questions, let me know!