Working with windows programming [GUI programming]:-
- working with from and controls is called as GUI programming.
- Windows programming supports to develop disk top applications, games, animations, Rich interactive, applications, etc,…………
- Formworks like a container, where any number of controls can be placed.
- The form is also called as WIN FORM (Windows form)
- Every Form is a class that must be inherited from a predefined class called FROM.
Class Test: Form
Test form name
Developing a user-defined from at the run time.
open windows form application project
place a button
code in GD
Class Test: Form
Code for Button 1_ click
Test t = new Test ();
- Back color = color. Green;
- show ();
Interested in mastering .NET? Learn more about ".NET Training" in this blog post.
Every Form will be associated with three files
Working with FORM properties:- (F4)
- Name: - this property changes object names with controls and class name with Forms
- Back color: Background color changes
- Fore color:-
- Background Image
- Background Image Layout
- Opacity (transparent): when this value is decreasing then the transparency ratio will be increasing (2……………..100)
- Transparency key:- this value must be the same as form back color.
Then except form, the border and controls body remaining port will be displayed fully transparent.
- Form border-style : none
- Window state : normal / Minimize / Maximize
Developing a Screen Saver :-
Generally, Screen saves are.SCR files, which will be under c:/windows/system 32 folder Open windows forms application project with project name Abcd (output file will be abcd. exe)
Form properties (F4) and set Back color = black Form border style = none. Window state = maximize
- Place a picture Box control propertiesimage = select an Image
- Place a timer control àproperties enabled = true
- Code in GD. Int x = 0;
- Code for Timer 1_Tick
X = x +5;
If (x > 400) X = 0;
Picture box 1. Location = new point (x, x);
Code for Form 1 key press event ( Form 1 àproperties àclick on yellow colored Icon (events)àdouble click on key press )
Application .Exit ();
Execute the Project (F5)
Abcd .exe file will be created under
D:/c 194/abcd/bin/debug Folder
Rename Abcd .exe with Abcs.Scr
copy Abcd .Scr in to C :/windows / system 32 folder; Then check box desktop properties
Form Properties continuation:-
Context menu Strip :
- The Associated context menu strip control will be displayed when right-clicked on an object.
Example on context menu strip:-
Display an Icon in Systems along with context menu strip.
- Open windows form application project
- Place a color – dialog control
- Place a context menu strip control on the form
- Design context menu strip with the following options
- Code for colors menu Item ( double click on colors)
- Color Dialog 1. Show Dialog ();
- this. Back color = color Diaglog1. Color;
- Code for Exit menu Item
- Application .Exit ();
- Place a notify Icon control à properties à Icon = select icon file
- Context menu strip = context menu strip 1 à name of the control.
Execute the project (F5) Then observe the system’s tray for a new icon
Form properties Continuation
- Accept button: the Associated button will be executed when pressed “Enter key”
- Cancel Button: the associated button will be executed when pressed “Escape key”
àOpen windows form Application project àPlace five text boxes and two buttons
Code for button 1 _ click
This. Back color = color .Green ;
à code for button2_ click (clearing the text boxes)
For each (control c in this. controls)
If (c. Get type (). Name == “Text box”)
text = “”;
- Choose from properties
Accept Button = Button 1
Cancel Button = Button 2