• Home
  • Blog
  • .NET
  • Working with windows programming [GUI programming] in C# .Net

Working with windows programming [GUI programming] in C# .Net

Ratings:
(4)
Views: 765
Banner-Img
Share this blog:

 

 Working with windows programming [GUI programming]:-

  1. working with from and controls is called as GUI programming.
  2. Windows programming supports to develop disk top applications, games, animations, Rich interactive, applications, etc,…………
  3. Formworks like a container, where any number of controls can be placed.
  4. The form is also called as WIN FORM (Windows form)
  5. Every Form is a class that must be inherited from a predefined class called FROM.

  Class Test: Form

{

  }

  Test arrrowform name

Formarrrowpredefined class  

Example :

Developing a user-defined from at the run time.  

arrrowopen windows form application project

arrrowplace a button

arrrowcode in GD  

Class Test: Form

Code for Button 1_ click

Test t = new Test ();

  1. Back color = color. Green;
  2. show ();

 Interested in mastering .NET? Learn more about ".NET Training" in this blog post.

Every Form will be associated with three files

  Screenshot_61  

Working with FORM properties:-  (F4)  

  1. Name: - this property changes object names with controls and class name with Forms
  2. Back color: Background color changes
  3. Fore color:-
  4. Font:-
  5. Background Image
  6. Background Image Layout
  7. Opacity (transparent): when this value is decreasing then the transparency ratio will be increasing  (2……………..100)
  8. 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.

  1. Form border-style : none
  2. 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 arrrowproperties  (F4) and set Back color = black Form border style  = none. Window state = maximize  

  • Place a picture Box control arrrow propertiesarrrowimage = select an Image
  • Place a timer control àproperties arrrow 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)  

OBS:-

  Abcd .exe file will be created under  

D:/c 194/abcd/bin/debug Folder  

Rename Abcd .exe with Abcs.Scr  

arrrowcopy Abcd .Scr in to C :/windows / system 32 folder; Then check box desktop properties

arrrowScreen saver  

Form Properties continuation:-

 Context menu Strip :

Screenshot_62    

  • 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.  

Screenshot_63  

  • 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

  Screenshot_64    

    • 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

  1. Accept button: the Associated button will be executed when pressed “Enter key”
  2. Cancel Button: the associated button will be executed when pressed “Escape key”

Screenshot_65    

  Example:-  

à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                

You liked the article?

Like: 2

Vote for difficulty

Current difficulty (Avg): Medium

EasyMediumHardDifficultExpert
IMPROVE ARTICLEReport Issue

About Author

Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox