Introduction to .NET Framework, C# (C Sharp) and Windows Forms

Microsoft .NET Framework

Microsoft .NET Framework is technology for building and running .NET applications. It provides a standard library of classes and a run-time environment called Common Language Runtime (CLR).CLR is the foundation of the .NET Framework. It manages code at execution time, memory management, thread management, remoting.
| | | | |
2017/10/05 03:59

c# combobox set selected item by item's text

C# Combobox defined with name my_combobox
private System.Windows.Forms.ComboBox my_combobox;

Define string variable with the text of the combobox item that has to be selected. For example, if the combobox items have text values "item_a" "item_b" "item_c" ... and the item which text is "item_b" has to be selected
| |
2017/10/05 02:52

C# - Get database connection string from Web.config file

To get the database connection string from IIS Web.config file using C# code, include System.Configuration directive and then create a string variable to assign the connection string like this:
using System.Configuration;
string connStr = ConfigurationManager.
If “ConfigurationManager” is not recognized you will need to add reference to: "System.Configuration".See: C# - How to add reference to project

| |
2017/10/05 02:45

C# Textbox - enter only positive numbers on KeyPress event in Windows form application

To prevent users from entering incorrect data in Windows form application, set restriction to allow only specific characters to be entered in the text box.This example uses KeyPress event to monitor the users input and to apply the restriction required.To avoid code duplication in Windows multiform applications for example, a separate class file is created “CommonFunctions.cs”.
The function to allow only numbers in textbox control is named InputNumbers.
For each Windows form, create a single KeyPress event and call the InputNumbers function inside it.
| |
2017/10/05 02:27


Coordinates in C#The value of x is the location of the point along the x-axis, the 0 is at the extreme left. The value of y is the location of the point along the y-axis, the 0 is at the extreme top.
| |
2017/10/05 01:56

C# Custom control – TextBox accepting only numbers, decimal numbers, signed numbers

The creation of custom control using Visual Studio involves the following steps:
  1. Start Visual Studio;
  2. Create new “Windows Control Library” project;
  3. In the created project delete “User Control” file;
  4. Go to “Project” > “Add User Control” and give it a name;
  5. Change the inherited class to this that you want your control to be;
  6. Create you custom properties for the control;
    | |
    2017/10/05 00:51