SlideShare a Scribd company logo
1 of 20
GUI Applications Development Using .NET Framework
Objectives


                In this session, you will learn to:
                   Work with user-defined components in the .NET applications




     Ver. 1.0                        Session 11                        Slide 1 of 20
GUI Applications Development Using .NET Framework
Creating a .NET Component


                To create a component in .NET, the user needs to identify
                the type of component and its properties and methods.
                While creating a component, a user needs to:
                   Use constructors
                   Add properties
                   Add methods




     Ver. 1.0                         Session 11                    Slide 2 of 20
GUI Applications Development Using .NET Framework
Creating a .NET Component (Contd.)


                Using Constructors:
                   .NET allows the passing of arguments to the object constructor
                   by adding a constructor to the component's class module.
                   A component can have the following types of constructors:
                      Public constructors
                      Internal constructors
                      Private constructors




     Ver. 1.0                        Session 11                          Slide 3 of 20
GUI Applications Development Using .NET Framework
Creating a .NET Component (Contd.)


                Adding Properties:
                – Declaring a property allows you to control how a value is
                  changed or read.
                – You can declare a private variable that cannot be accessed
                  from outside a class.
                – You can create a property where you can have the Get and
                  Set accessors to read and set the value of a private variable.




     Ver. 1.0                        Session 11                          Slide 4 of 20
GUI Applications Development Using .NET Framework
Creating a .NET Component (Contd.)


                Adding Methods:
                   A method in a class can be:
                      a procedure that performs an operation on the data within the
                      class.
                      a function that performs some operation on the data and returns
                      the data from the class.
                   The method must be declared public to call a method from an
                   instance of this class.
                   If a method is declared private, only methods within the same
                   class can call that method.




     Ver. 1.0                        Session 11                               Slide 5 of 20
GUI Applications Development Using .NET Framework
Just a minute


                Name the two main categories of .NET components.




                Answer:
                1. In-process components
                2. Out-of-process components

     Ver. 1.0                     Session 11                       Slide 6 of 20
GUI Applications Development Using .NET Framework
Creating User-Defined Controls in .NET Applications


                There may be situations when you require a control, which
                performs actions that are not provided by any built-in control
                or need some enhanced feature.
                The .NET Framework provides three types of user-defined
                controls. These are:
                   User control
                   Controls inherited from an existing control
                   Custom control




     Ver. 1.0                        Session 11                       Slide 7 of 20
GUI Applications Development Using .NET Framework
Creating User-Defined Controls in .NET Applications (Contd.)


                User Controls:
                – You combine two or more controls to create a new control.
                – User controls are also called as composite controls.
                – All user controls inherit the
                  System.Windows.Forms.UserControl class.
                – The UserControl class can be used to combine the
                  functionality of various controls into one unit, which can be
                  reused.
                – The UserControl class presents a single and unified
                  interface.
                – This interface contains members inherited from the control
                  classes.




     Ver. 1.0                        Session 11                            Slide 8 of 20
GUI Applications Development Using .NET Framework
Creating User-Defined Controls in .NET Applications (Contd.)


                Controls Inherited from an Existing Control:
                   You can inherit from an existing control and then add
                   additional features to it.
                   When you inherit a control from an existing control, the new
                   control will have all the features of the inherited control.




     Ver. 1.0                       Session 11                            Slide 9 of 20
GUI Applications Development Using .NET Framework
Just a minute


                Name the method that has to be overridden to change the
                appearance of the control that is inherited from an existing
                control.




                Answer:
                 – The OnPaint() method


     Ver. 1.0                      Session 11                         Slide 10 of 20
GUI Applications Development Using .NET Framework
Creating User-Defined Controls in .NET Applications (Contd.)


                Custom Controls:
                – Custom controls have the highest degree of customizability.
                – Users can build a control that has very little resemblance with
                  the built-in controls in terms of both appearance and
                  functionality.
                – All custom controls inherit from the
                  System.Windows.Forms.Control class.




     Ver. 1.0                       Session 11                            Slide 11 of 20
GUI Applications Development Using .NET Framework
Just a minute


                Name the class to be inherited for creating a custom
                control.




                Answer:
                   System.Windows.Forms.Control


     Ver. 1.0                      Session 11                          Slide 12 of 20
GUI Applications Development Using .NET Framework
Demo: Implementing a .NET Component


               Problem Statement:
                  Build a nonvisual .NET component called TimeComponent. It
                  should get the current date and time from the host computer. In
                  addition, create an application that will use this component and
                  display the time returned.




    Ver. 1.0                       Session 11                            Slide 13 of 20
GUI Applications Development Using .NET Framework
Demo: Implementing a .NET Component (Contd.)


               Solution:
                  To use a component, you need to perform the following tasks:
                    1. Create a .NET component.
                    2. Create a user application.




    Ver. 1.0                         Session 11                        Slide 14 of 20
GUI Applications Development Using .NET Framework
Demo: Creating a User Control


                Problem Statement:
                   Build a user control called DigitalClock. This should contain a
                   label control that displays time. In addition, create an
                   application that will use this control.




     Ver. 1.0                        Session 11                            Slide 15 of 20
GUI Applications Development Using .NET Framework
Demo: Creating a User Control (Contd.)


                Solution:
                   To build a user control and an application, you need to perform
                   the following tasks:
                     1. Create a user control.
                     2. Create a user application.




     Ver. 1.0                         Session 11                         Slide 16 of 20
GUI Applications Development Using .NET Framework
Demo: Creating Inherited Controls


                Problem Statement:
                   Build a NumericTextBox control that contains a TextBox
                   control. The latter should accept only a numeric value as input.
                   In addition, create an application that will use this control.




     Ver. 1.0                       Session 11                            Slide 17 of 20
GUI Applications Development Using .NET Framework
Demo: Creating Inherited Controls (Contd.)


                Solution:
                   To create the NumericTextBox control and an application,
                   which will implement the NumericTextBox control, you need to
                   perform the following tasks:
                     1. Create an inherited control.
                     2. Create a user application.




     Ver. 1.0                          Session 11                      Slide 18 of 20
GUI Applications Development Using .NET Framework
Summary


               In this session, you learned that:
                  To create a component in .NET, the user needs to identify the
                  type of component and its properties and methods.
                  While creating a component, a user needs to:
                    •   Use constructors
                    •   Add properties
                    •   Add methods
                  In .NET programming environment, you can have the following
                  types of constructors:
                        Public constructor
                        Internal constructor
                        Private constructor




    Ver. 1.0                           Session 11                       Slide 19 of 20
GUI Applications Development Using .NET Framework
Summary (Contd.)


               The .NET Framework provides three types of user-defined
               controls. These are:
                   User controls
                   Controls inherited from an existing control
                   Custom controls




    Ver. 1.0                      Session 11                      Slide 20 of 20

More Related Content

Viewers also liked

02 iec t1_s1_plt_session_02
02 iec t1_s1_plt_session_0202 iec t1_s1_plt_session_02
02 iec t1_s1_plt_session_02Niit Care
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# IntroductionSiraj Memon
 

Viewers also liked (7)

09 gui 13
09 gui 1309 gui 13
09 gui 13
 
04 gui 05
04 gui 0504 gui 05
04 gui 05
 
02 gui 02
02 gui 0202 gui 02
02 gui 02
 
10 gui 14
10 gui 1410 gui 14
10 gui 14
 
01 gui 01
01 gui 0101 gui 01
01 gui 01
 
02 iec t1_s1_plt_session_02
02 iec t1_s1_plt_session_0202 iec t1_s1_plt_session_02
02 iec t1_s1_plt_session_02
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
 

Similar to 08 gui 11

Vb.net session 10
Vb.net session 10Vb.net session 10
Vb.net session 10Niit Care
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17Niit Care
 
Vb.net session 09
Vb.net session 09Vb.net session 09
Vb.net session 09Niit Care
 
GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.pptTabassumMaktum
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Niit Care
 
09 intel v_tune_session_13
09 intel v_tune_session_1309 intel v_tune_session_13
09 intel v_tune_session_13Vivek chan
 
Unit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdfUnit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdfKaty Slemon
 
Vb.net session 02
Vb.net session 02Vb.net session 02
Vb.net session 02Niit Care
 
Vb net xp_14
Vb net xp_14Vb net xp_14
Vb net xp_14Niit Care
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17Vivek chan
 
Vb net xp_13
Vb net xp_13Vb net xp_13
Vb net xp_13Niit Care
 
Vb net xp_16
Vb net xp_16Vb net xp_16
Vb net xp_16Niit Care
 
My Very First Zf App Part One
My Very First Zf App   Part OneMy Very First Zf App   Part One
My Very First Zf App Part Oneisaaczfoster
 
Moving to Microsoft Visual Basic .NET
Moving to Microsoft Visual Basic .NETMoving to Microsoft Visual Basic .NET
Moving to Microsoft Visual Basic .NETV Sanchez
 
Building DotNetNuke Modules
Building DotNetNuke ModulesBuilding DotNetNuke Modules
Building DotNetNuke ModulesEngage Software
 

Similar to 08 gui 11 (20)

Vb.net session 10
Vb.net session 10Vb.net session 10
Vb.net session 10
 
VB.Net GUI Unit_01
VB.Net GUI Unit_01VB.Net GUI Unit_01
VB.Net GUI Unit_01
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
Vb.net session 09
Vb.net session 09Vb.net session 09
Vb.net session 09
 
06 gui 08
06 gui 0806 gui 08
06 gui 08
 
GUI design using JAVAFX.ppt
GUI design using JAVAFX.pptGUI design using JAVAFX.ppt
GUI design using JAVAFX.ppt
 
Custom Widgets Tutorial InTouch Machine Edition (ITME)
Custom Widgets Tutorial InTouch Machine Edition (ITME)Custom Widgets Tutorial InTouch Machine Edition (ITME)
Custom Widgets Tutorial InTouch Machine Edition (ITME)
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
 
09 intel v_tune_session_13
09 intel v_tune_session_1309 intel v_tune_session_13
09 intel v_tune_session_13
 
Unit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdfUnit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdf
 
Vb.net session 02
Vb.net session 02Vb.net session 02
Vb.net session 02
 
Vb net xp_14
Vb net xp_14Vb net xp_14
Vb net xp_14
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
 
Vb net xp_13
Vb net xp_13Vb net xp_13
Vb net xp_13
 
Vb net xp_16
Vb net xp_16Vb net xp_16
Vb net xp_16
 
My Very First Zf App Part One
My Very First Zf App   Part OneMy Very First Zf App   Part One
My Very First Zf App Part One
 
Moving to Microsoft Visual Basic .NET
Moving to Microsoft Visual Basic .NETMoving to Microsoft Visual Basic .NET
Moving to Microsoft Visual Basic .NET
 
Building DotNetNuke Modules
Building DotNetNuke ModulesBuilding DotNetNuke Modules
Building DotNetNuke Modules
 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

08 gui 11

  • 1. GUI Applications Development Using .NET Framework Objectives In this session, you will learn to: Work with user-defined components in the .NET applications Ver. 1.0 Session 11 Slide 1 of 20
  • 2. GUI Applications Development Using .NET Framework Creating a .NET Component To create a component in .NET, the user needs to identify the type of component and its properties and methods. While creating a component, a user needs to: Use constructors Add properties Add methods Ver. 1.0 Session 11 Slide 2 of 20
  • 3. GUI Applications Development Using .NET Framework Creating a .NET Component (Contd.) Using Constructors: .NET allows the passing of arguments to the object constructor by adding a constructor to the component's class module. A component can have the following types of constructors: Public constructors Internal constructors Private constructors Ver. 1.0 Session 11 Slide 3 of 20
  • 4. GUI Applications Development Using .NET Framework Creating a .NET Component (Contd.) Adding Properties: – Declaring a property allows you to control how a value is changed or read. – You can declare a private variable that cannot be accessed from outside a class. – You can create a property where you can have the Get and Set accessors to read and set the value of a private variable. Ver. 1.0 Session 11 Slide 4 of 20
  • 5. GUI Applications Development Using .NET Framework Creating a .NET Component (Contd.) Adding Methods: A method in a class can be: a procedure that performs an operation on the data within the class. a function that performs some operation on the data and returns the data from the class. The method must be declared public to call a method from an instance of this class. If a method is declared private, only methods within the same class can call that method. Ver. 1.0 Session 11 Slide 5 of 20
  • 6. GUI Applications Development Using .NET Framework Just a minute Name the two main categories of .NET components. Answer: 1. In-process components 2. Out-of-process components Ver. 1.0 Session 11 Slide 6 of 20
  • 7. GUI Applications Development Using .NET Framework Creating User-Defined Controls in .NET Applications There may be situations when you require a control, which performs actions that are not provided by any built-in control or need some enhanced feature. The .NET Framework provides three types of user-defined controls. These are: User control Controls inherited from an existing control Custom control Ver. 1.0 Session 11 Slide 7 of 20
  • 8. GUI Applications Development Using .NET Framework Creating User-Defined Controls in .NET Applications (Contd.) User Controls: – You combine two or more controls to create a new control. – User controls are also called as composite controls. – All user controls inherit the System.Windows.Forms.UserControl class. – The UserControl class can be used to combine the functionality of various controls into one unit, which can be reused. – The UserControl class presents a single and unified interface. – This interface contains members inherited from the control classes. Ver. 1.0 Session 11 Slide 8 of 20
  • 9. GUI Applications Development Using .NET Framework Creating User-Defined Controls in .NET Applications (Contd.) Controls Inherited from an Existing Control: You can inherit from an existing control and then add additional features to it. When you inherit a control from an existing control, the new control will have all the features of the inherited control. Ver. 1.0 Session 11 Slide 9 of 20
  • 10. GUI Applications Development Using .NET Framework Just a minute Name the method that has to be overridden to change the appearance of the control that is inherited from an existing control. Answer: – The OnPaint() method Ver. 1.0 Session 11 Slide 10 of 20
  • 11. GUI Applications Development Using .NET Framework Creating User-Defined Controls in .NET Applications (Contd.) Custom Controls: – Custom controls have the highest degree of customizability. – Users can build a control that has very little resemblance with the built-in controls in terms of both appearance and functionality. – All custom controls inherit from the System.Windows.Forms.Control class. Ver. 1.0 Session 11 Slide 11 of 20
  • 12. GUI Applications Development Using .NET Framework Just a minute Name the class to be inherited for creating a custom control. Answer: System.Windows.Forms.Control Ver. 1.0 Session 11 Slide 12 of 20
  • 13. GUI Applications Development Using .NET Framework Demo: Implementing a .NET Component Problem Statement: Build a nonvisual .NET component called TimeComponent. It should get the current date and time from the host computer. In addition, create an application that will use this component and display the time returned. Ver. 1.0 Session 11 Slide 13 of 20
  • 14. GUI Applications Development Using .NET Framework Demo: Implementing a .NET Component (Contd.) Solution: To use a component, you need to perform the following tasks: 1. Create a .NET component. 2. Create a user application. Ver. 1.0 Session 11 Slide 14 of 20
  • 15. GUI Applications Development Using .NET Framework Demo: Creating a User Control Problem Statement: Build a user control called DigitalClock. This should contain a label control that displays time. In addition, create an application that will use this control. Ver. 1.0 Session 11 Slide 15 of 20
  • 16. GUI Applications Development Using .NET Framework Demo: Creating a User Control (Contd.) Solution: To build a user control and an application, you need to perform the following tasks: 1. Create a user control. 2. Create a user application. Ver. 1.0 Session 11 Slide 16 of 20
  • 17. GUI Applications Development Using .NET Framework Demo: Creating Inherited Controls Problem Statement: Build a NumericTextBox control that contains a TextBox control. The latter should accept only a numeric value as input. In addition, create an application that will use this control. Ver. 1.0 Session 11 Slide 17 of 20
  • 18. GUI Applications Development Using .NET Framework Demo: Creating Inherited Controls (Contd.) Solution: To create the NumericTextBox control and an application, which will implement the NumericTextBox control, you need to perform the following tasks: 1. Create an inherited control. 2. Create a user application. Ver. 1.0 Session 11 Slide 18 of 20
  • 19. GUI Applications Development Using .NET Framework Summary In this session, you learned that: To create a component in .NET, the user needs to identify the type of component and its properties and methods. While creating a component, a user needs to: • Use constructors • Add properties • Add methods In .NET programming environment, you can have the following types of constructors: Public constructor Internal constructor Private constructor Ver. 1.0 Session 11 Slide 19 of 20
  • 20. GUI Applications Development Using .NET Framework Summary (Contd.) The .NET Framework provides three types of user-defined controls. These are: User controls Controls inherited from an existing control Custom controls Ver. 1.0 Session 11 Slide 20 of 20

Editor's Notes

  1. Start the session by sharing the session objectives with the students.
  2. Using this slide, the faculty must discuss with the students that they can create components in .NET. These components may comprise of constructors to initialize data members. In addition, it can include set and get methods to initialize properties and methods to perform some specific tasks.
  3. Using this slide, the faculty must discuss with the students the three types of constructor that a .NET component can have.
  4. Using this slide, the faculty must discuss with the students the way of adding properties to a .NET component. The faculty should discuss the purpose of Set and Get methods in modifying the value of properties.
  5. Using this slide, the faculty must discuss that methods can be created within components. These methods are normal functions to perform a particular task that may or may not return a value. The faculty should also discuss the access specifiers that can be used with the methods and the effect of using these access specifiers.
  6. Reiterate the concepts taught earlier by asking the given question.
  7. Use this slide to discuss that it is possible to create three different types of controls in .NET. These have been listed in the slide. The faculty can give an example to make the students understand these in a better way. User Control: You combine two or more controls to create a new control. The new control will act like a single control. User controls are also called as composite controls . For example, a control is created using a form and a text box to connect to a database. Inheriting form an existing control: You may require some additional function to be added to an existing control. You can inherit from an existing control and then add the required features to it. The faculty can use the same example of a numeric text box. Custom Control: Custom controls have the highest degree of customizability. You may require a control that has very little resemblance with the built-in controls in terms of both appearance and functionality. The faculty can explain the example from the SG - if you need an analog clock control, combining controls or inheriting a control will be of very little help. You will have to create the control from scratch. The following four slides discuss these in detail.
  8. Use this slide to discuss the steps for creating user control. It will be a good teaching practice to demonstrate this with the help of a small example.
  9. Reiterate the concepts taught earlier by asking the given question.
  10. Reiterate the concepts taught earlier by asking the given question.
  11. Conduct the activity stated in the slide in a collaborative mode in the class.
  12. Conduct the activity stated in the slide in a collaborative mode in the class.
  13. Conduct the activity stated in the slide in a collaborative mode in the class.
  14. Conduct the activity stated in the slide in a collaborative mode in the class.
  15. Conduct the activity stated in the slide in a collaborative mode in the class.
  16. Conduct the activity stated in the slide in a collaborative mode in the class.
  17. You can summarize the session by using the summary given in the slides. In addition, you can also ask students summarize what they have learnt in this session.
  18. You can summarize the session by using the summary given in the slides. In addition, you can also ask students summarize what they have learnt in this session.