Skip to main content

How to add Controls to a Blank C# Form

If you want to add a control to a form, you can use the Toolbox on the left of Visual Studio. Move your mouse over to the Toolbox, and click the plus symbol next to Common Controls. You should see the following list of things that you can add to your form:
Toolbox


Click the Button item under the Common Controls heading. This will select it. Now click once anywhere on your form. A button will be drawn for you, and your Form will look like this:

Form
                                         

Similarly you can drag and drop different controls on the Form According to your requirements.
The text on the button, which defaults to "button1", can be changed from properties windows.

 A property of a control is things like its Height, its Width, its Name, its Text, and a whole lot more besides. To see what properties are available for a button, make sure the button is selected, as in the image below:

                                                 

Now look in the bottom right of Visual C# Express, just below the Solution Explorer. You should see the Properties Window (if it's not there, select it from the View menu at the top. Again, 2010 users need to click Tools > Settings > Expert Settings to see the full list of menu items.):

                                                           

                        From this window you can customize the button according to your need
To view the list of Properties in alphabetical order, click the AZ symbol at the top of the property window.
As you can see, there's a lot of Properties for a button. Scroll down to the bottom and locate the Text Property:
The Text Property, as its name suggests, is the Text you want to appear on the button. At the moment, it says button1. Click inside of the text area of button1. Delete the default text:
Now type the following:

                                                           Message

The Text part of your Properties Window will then look like this:


Now press the enter key on your keyboard. Have a look at your Form, and the Text on the button should have changed:
                                                                 
In next session i will tell you how to write events in code behind file.
Happy Programming..:)

Comments

Post a Comment

Popular posts from this blog

ASP.NET AJAX PasswordStrength Extender

  AJAX Password Strength Extender shows the strength of user chosen passwords.the strength can be show in a  text form, a bar indicator or combination of both.Now i am going to show you how to add ajax password extender control to a asp.net page, In case of Visual studio 2005 install AjaxControlToolkit and in case of Visual studio 2010 add AjaxControlToolkit.dll in the project. I have added a text box and a label control in the page and page will be look like this:                                               After that Add password strength code in the aspx file of the web page. <body>     <form id="form1" runat="server">         <asp:ScriptManager ID="ScriptManager1" runat="ser...

ASP.NET MVC 5 (Part 2)

Before you start this tutorial, you should have the knowledge about, how to create an ASP .NET MVC   web application. MVC stands for the model- View- controller. MVC is an architectural pattern for developing applications that are well architectured, testable and easy to maintain. MVC application contains: Model : classes represent the data of the application. A model does not depend on the controller and view classes. View : Display the model data and send user action (button click) to the controller. Controller : provides the model data to the view and interprets user actions like button click. the controller depends on the model and the view. Controller Let 's start by adding a controller class in MVCProject .In Solution Explorer, right click on the controller folder and select controller.   In the Add scaffold dialogue box,  select MVC 5 controller-empty and then click Add. Name your controller FirstTest, and click the A...

How to send Email through ASP.NET in C#

Sending Email through ASP.NET is very easy.the .NET framework comes with a namespace which is uses for handling the Email.The namespace is:                                                            System.Net.Mail namespace Here i am using the two classes of the above mentioned namespace.The first class is MailMessage  class which is used for actual email and second is SmtpClient class which is for sending Email. Write the following code into the page load event: try { MailMessage mailMessage = new MailMessage(); mailMessage.To.Add( " test@domain.com " ); mailMessage.From = new MailAddress( " test2 @ domain.com " ); mailMessage.Subject = " Test Email " ; mailMessage.Body = " This is an ASP.NET test E-mail! " ; SmtpClient smtpClient = new SmtpClient( " smtp .te...