This website uses cookies to improve service and provide non-personalized ads. By using this site, you agree to this use. See our Privacy Policy and Cookies Info .
Yes, I agree. No, I do not agree.

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

| 2017/10/05 02:27

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.

c# passing data between forms

| 2017/10/05 02:07
C# project with two forms
public partial class Form1 : Form // this is the main form

public partial class Form2 : Form // this is the second form
To pass variables (values, data) from Form1 to Form2
Case: public variables in Form2
public string input_variable; // put this in Form2 as global variable

public string output_variable; // put this in Form2 as global variable

in Form1 inside the function that run (call) Form2
TAGS:

C# How to draw shapes – Circle, Rectangle, Arc, Pie, Polygon, Bezier, Text

| 2017/10/05 01:56
In order to draw shapes in C# a start point and end point coordinates, and a Pen control must be defined first.
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.
TAGS: |

C# - How to add reference to project

| 2017/10/05 01:31
To add a reference to CSharp project do the following:
  1. Open “Solution Explorer”;
  2. Right click “References”;
  3. Choose “Add Reference”.



On the Reference Manager Window go to: “Assemblies” -> “Framework”.

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

| 2017/10/05 00:51

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;

Visual Studio – Add custom control DLL to toolbox

| 2017/10/05 00:37
To add a custom control to VisualStudio project:1) Go to “Toolbox” tab;2) Right click on it and click “Choose Items…”;

3) In the “Choose Toolbox Items” window click on the “Browse…” button.Navigate to the location where your Dynamic Link Library (DLL) file is.Click “OK”. Now your custom control is included into the Visual Studio toolbox.
TAGS: |

Handling CheckedListBox ItemCheck event in C#

| 2015/11/19 10:16
Common problem handling ItemCheck event in CheckedListBox control is the fact that when the event is fired the object's state change is not finalized.If within the ItemCheck event handling function we try to get the CheckedListBox item's check state using the most common methods like getting collection of all checked items
TAGS: