SlideShare a Scribd company logo
1 of 20
Download to read offline
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

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Which standard is best for your content?
Which standard is best for your content?Which standard is best for your content?
Which standard is best for your content?Rustici Software
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Arti Languages Pre Seed Pitchdeck 2024.pdf
Arti Languages Pre Seed Pitchdeck 2024.pdfArti Languages Pre Seed Pitchdeck 2024.pdf
Arti Languages Pre Seed Pitchdeck 2024.pdfwill854175
 
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...BookNet Canada
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Transport in Open Pits______SM_MI10415MI
Transport in Open Pits______SM_MI10415MITransport in Open Pits______SM_MI10415MI
Transport in Open Pits______SM_MI10415MIRomil Mishra
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 

Recently uploaded (20)

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Which standard is best for your content?
Which standard is best for your content?Which standard is best for your content?
Which standard is best for your content?
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Arti Languages Pre Seed Pitchdeck 2024.pdf
Arti Languages Pre Seed Pitchdeck 2024.pdfArti Languages Pre Seed Pitchdeck 2024.pdf
Arti Languages Pre Seed Pitchdeck 2024.pdf
 
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Transport in Open Pits______SM_MI10415MI
Transport in Open Pits______SM_MI10415MITransport in Open Pits______SM_MI10415MI
Transport in Open Pits______SM_MI10415MI
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 

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.