Before .Net, a technology named COM (Component Object Model) was used to develop applications.
* COM is specification for building application
* Supporting languages for COM are
* VB 6.0 – desktop application
* C++ – good for system level programming
* VC ++ – extended version of c++
* VFoxpro – database integrated frontend
Like this each language has its own specialty.
To develop an application in VB 6.0 and need something from VC++ then we use COM to communicate the both i.e. VB 6.0 talk through COM to VC++ and vice versa.
– Every COM supportive language has its own features and also has COM supported features
– By using COM we can do anything or can develop any type of package but
– COM is not complete Object Oriented and today’s applications demand Object Oriented Concept
– COM is platform dependant i.e. COM applications run only on Windows OS
– COM applications are good for Intel architecture that means Hardware or Processor dependency
In the mean time SUN and APPLE produced Languages / Packages that are fully Object Oriented and platform independent and can be made hardware independent, but not very flexible, simplified to develop applications. That is where .Net comes with the architecture of platform and Hardware Independent applications and fully Object Oriented with same COM flexibility.
The Essay on Object Oriented Programming Smalltalk Class Language
... costs. Object-Oriented Languages There are almost two dozen major object-oriented programming languages in use today. But the leading commercial object-oriented languages ... project that invented the Smalltalk language. VisualWorks is platform-independent, so that an application written under one operating ... by most to be significantly faster to develop than C++ programs. A rich class library ...
Why .Net ?
.Net is a new technology from Microsoft for building applications of different types like console application, windows application, web application, mobile application etc.
.Net contains
1. Framework
2. Languages
3. Servers
4. Utilities
What is .Net ?
.Net is a Technology or platform that provides a standardized set of services.
Features of .Net :
1. It is not a package not a language
2. Complete object oriented
3. Platform independent/ hardware independent
4. Supports multiple languages like VB.Net, C#.Net, Cobol.Net, J#.Net etc.
5. Event driven programming
Framework :
* It is a programming model for .net
* Platform for running .net managed code in Virtual Machine (CLR)
* Provides a very good environment to develop network applications and web services
* Provides programming API and unified language independent development framework.
.Net contains Framework and the frame work contains
1. BCL (Base Class Libraries)
2. CLR (Common Language Runtime)
Base Class Libraries :
(i) Rich – provide functionality of many languages
(ii) Designed for any language
(iii) Object oriented
(iv) Hardware independent
* All past MS languages libraries and other language libraries are available in BCL
* There is no VB library, VC++ library separately all are .net library.
* To use libraries we need a language. Today .net has almost 50+ supportive languages.
* A .net language has no libraries on its own today and also has no runtime on its own.
* A language uses .net BCL as its library and uses .net CLR as its Run time
.net language + .net framework = application
C#.net + .net framework = c# appication
CLR (Common Language Runtime)
* Base class libraries are common but are understood only by CLR. These are not understood by VB.net or C#.net
* Contains Garbage Collection, Language Integration, Multiple versioning support
Code compilation and Execution :
Source code Language Compiler MSIL JIT compiler Native Code
The Essay on My Language Experience One Class English
It all started when my father came home, to Romania that is, for the first time since he fled the country, and he said to me "You " re going to America... ." I was emotionally aroused on the outside, but inside I was screaming. How will I communicate with others if I don't speak English. I won't have any friends, I'll be lonely. That feeling of emptiness stayed with me 'til this day So we finally ...
* MSIL code is called Assembly
* In .net assemblies are the key units
* All language compilers produce MSIL in the form of file called Assembly
* Assembly is the distributable or deployable unit of .Net
C#.net Program Structure :
.Net application
|
Name space(s)
|
Class (es)
|
Member (s)
|
Block (s)
|
Statement (s)
– Every MS.Net language is object oriented
– Every statement must be written inside a class
– Every class that we create contain members of different types like fields, properties, methods etc
– C# program structure is different for different types of applications (like for console application one method and windows application another or extending 1st method and for web applications again different method)
– All types of apps will contain code in the form of class only
– If we do not enter namespace the compiler will take default by some other name space i.e. global
– By default vs.net create a folder for every project that we create new.
– Every created folder contain another folder called bin folder. This folder is used by vs.net to store assemblies. The current project assembly and also other assemblies if needed.
– In c# for every data type there is a class eg. int is a class
– Parse is a function to convert data types
Environment :
1. Type ‘Devenv’ in ‘Run’ to open Microsoft Visual Studio
2. Right most corner of window you will find icons to work with
3. Solution explorer to see what our application contains
4. Click on Properties window icon or press F4 to open properties window
5. Tool box to open the list of controls available
6. F5 or ctrl+F5 to run the application.
7.
Controls :
Each and every Control in .Net is a class. Button, Textbox, Label, Combo box, list box etc are all controls and every control contains properties, methods and events.
Properties : Properties specify the look and feel of the controls.
The Term Paper on Property Rights Of Women In Nineteenth-Century England
The property rights of women during most of the nineteenth century were dependent upon their marital status. Once women married, their property rights were governed by English common law, which required that the property women took into a marriage, or acquired subsequently, be legally absorbed by their husbands. Furthermore, married women could not make wills or dispose of any property without ...
Methods : Methods are the actions performed on the controls.
Events : Events are the actions performed by the controls.
C#.net Windows Forms
Form :
– Form is a container control which can hold all other control that means any other control should be placed in form only.
– System.Windows.Forms is a .net namespace that is used to develop windows or desktop applications
– A desktop/windows app is the one that runs where ever its code is present. It completely uses resources of the client system
– All windows apps are GUI apps. System.Windows.Forms contain many classes like Form, Button, Textbox, label etc etc
– Every windows app means one or more classes extending FORM class
– A C#.net project can have one or more forms and can be designated with one startup form
– A startup form is set using Application.Run (new <formname>) – which will be available in Program.cs
– By default every form that we create is a class and we must instantiate it to view. A project has only one startup form and other forms must be explicitly loaded.
– Every control we create must be instantiated and added to the form container. Visual Studio .net has form designer where we can just drag and drop a control, arrange it and also write code for it. All the required work is carried out automatically by VS.Net.
– Form can be displayed as model or modeless window.
– A model window is a response window or a dialog box that does not allow user to interact with other forms of application. Model window can be displayed using Showdialog() method.
– A modeless window allows user to switch between any other windows within the application and displayed using Show() method
Label : It is used just to display some information on the form
Properties : Autosize
Button : To accept any action/confirmation from user
Properties : Height, Width, Backcolor, Forecolor
Events : Click
Textbox : This is the control used to get some information or input from the user.
Properties : multiline, maxlength, passwordchar, scrollbars, wordwrap
The Essay on Rock Music Form Brookhiser Listen
Rock is a popular form of music that has evolved over the past couple of decades starting in the 1950 s until present day. Rock music has been know to be used as a form of expression over the years. Despite its sometimes negative and defiant lyrics, rock is a form of art that allows one to release his / her feelings through singing in an expressive tone. I personally don't see problem with people ...
Events : textchanged, keypress, leave
Check box : used to accept data which is in the form of Boolean like yes/no, true/false etc. .Net check box supports 3 states instead of regular two state check box. The third state is called ‘Indeterminate Stage’.
By default 2 states only if needed we can use third state, by making ‘three state property’.
Properties : Threestate, checked, checkstate
Events : Checkedchanged : Fires whenever the status is changed
Radio button : To accept input by providing list of choices. Radio buttons work with group concepts in a group only single value is allowed and group is specified based on its container. By default, wherever we place radio button that acts as a container. A group of radio buttons represent a single value.
Properties : Checked
Tab Control : Every modern UI will be involved with a tabbed interface like VS.Net itself, word, excel etc. To create tabbed interface we use tab control.
– It has a collection of tab pages
– Every tabpage is one group, so we can place radio buttions in a tab page and set it as one group.
Group box and Panel :
– Both are containers
– Group box has a title area and a text property to set the title
Panel has no title area/ text property (if needed we can place a label in place of caption)
– Group box has no scrolling capabilities
Panel has auto scroll property that enables its content to scroll the data.
– Group box is a light weight control than panel
Picture box : If we want to display images as part of form then we can use picture box.
Properties : image – takes stream but not the file
Sizemode – stretch/autosize/center image
Note : c# supports escape sequences so while using path ” is not accepted, so change all ” to ‘\’ or use @ (verbatim string) before the string.
Eg : Picturebox1.Image = Image.fromfile (@”e :…..”);
(All controls that are not visible at runtime are kept in a separate tray called component tray)
The Essay on Property belonging
According to the document, “The Unclaimed Property Rage”, by Mark Kantrowitz, most unclaimed property becomes abandoned as a result of three events. The first of these events is the change of address of the owner. That is, if the owner of the property has moved and left the property behind, it can be considered unclaimed. The second method by which property may become abandoned is through the ...
– List controls are the most needed and dynamic supporting controls. Some of the list and its related controls are listbox, combobox, checked listbox, listview, treeview etc. All these controls play an important role in apps and these controls properties and methods are common except for few interface and property changes. The collections used are also //ar.
– List box and combo box both provide users- list of values that can be handled dynamically in a much better than radio buttons, check boxes etc. Some of the differences between list box and combo box are
– user interface (Combo consumes less space)
– List box allows multiple selection and combo only single selection
– Read only values/select only values in list box
Read and Type – (combination of list box and text box)
Collection is like an array but having methods and properties.
Items (collection)
– Every list control has a collection called items
– Items represent all elements in the control
item[0] represents first element
– Items can be added at design time using properties window and at runtime with its methods and properties. Run time behaviour is very important.
Runtime Methods and Properties of items
1. Add (<value>) – adds the element at the end of list box
eg : Listbox1.items.add (“Asp.Net”);
2. Insert (<value>, position) – insert the element at the specified position
eg : Listbox1.items.Insert (“framework”, 0)
3. Remove (<value>) – Removes the first occurance of an element
eg : Listbox1.items.Remove (“framework”)
4. Remove at(<index>) – Removes the specified element by using the index property.
eg : Listbox1.items.removeat(Listbox1.selectedindex);
5. Count – Gives the total no. of elements in the list box
eg : Listbox1.items.count;
6. Clear – Clears all the elements from the list box.
Properties :
1. Selecteditem : Displays or views the currently selected element. Error if no element is selected.
eg. Listbox1.selecteditem.tostring();
Note : All list box elements are by default of type object thats why it can show a string, a no. and image etc. and when we want value in string, integer forms then we must explicitly convert it.
The Research paper on Deva Student’s Property Website Development
In the United Kingdom, different scholars have noted the rapid increase in the housing demand an aspect created by the increase in the number of international and even local students in the UK based Universities and colleges. Consequently, this results to creation of large commercial markets in the provision of rental related services in the respective university towns, a market that is satisfied ...
2. SelectedIndex : Gives the currently selected items index.
Note : It returns -1 when no selection is made, can be used for validations
3. Selection Mode : one (default), multisimple (toggle), multiextended (explorer style using ctrl+shift)
4. Selecteditems : provides list of elements that are selected
eg : for each (string s in listbox1.selecteditems)
{
listbox2.items.add(s);
}
5. Selectedindices : Returns the selected element index instead of value
6. FindString (<string>) : Searches the given string and returns the index of the element. It searches even substring of any element.
eg : Listbox1.findstring(“asp”)
7. Findstringexact (<String>) : Searches for the given full string and returns its index
eg : Listbox1.findstringexact(“asp”)
8. GetSelected : Returns true if nth element is selected and false if not selected
eg : Listbox1.getselected(listbox1.findexactstring(“India”)
Notify Icon : Used to display the tray icon in system tray. (earlier we use windows API and produce this result)
Properties : Icon, text
Balloontiptext, balloon tip title, balloon tipicon properties
Eg : Notifyicon1.showballoontip (2000); (milliseconds)
ContextMenuStrip : To display menu when we right click on the tray icon we must use another control called context menu, design it write code for it and attach to the required control using context menu property.
Timer : To execute code at regular intervals timer control is used.
Properties : Interval – in milliseconds – 1000 milliseconds = 1 sec
Updown control : this control is used when a range of numeric values are required, which can be incremented or decremented accordingly using properties.
Properties : minimum – to set the starting value of up-down control
maximum – to set the max value
increment : to set the value to be incremented when ever arrows are clicked
LinkLabel : The Link Label control is used to execute the links of other files and web pages. Link Label is a class which is derived from label class so it has all the functions of label class. It works like a hyperlink. The link can change color to indicate whether the link is new, visited or active. When clicked, the Link Label fires a Link Clicked event.
Masked Text Box : This control is used like text box besides it also has a ‘mask’ property to restrict the user or validate the control. This control has already some built-in masks and by using ‘custom’ mask we can have user defined masks.
Eg : 00000 – 5 digits
LLLL – 4 characters
0000-LLLL – 4 digits, 4 characters
Dialog Boxes : Dialog boxes are standard windows forms that are used in various situations like opening file, saving file, printing, color and font. To design all these it is difficult and using .net dialog boxes we can get the operating boxes into our program. If all these donot fulfill the requirement, then we can create our own form as a dialogbox using showdialog method instead of show method.
RichTextBox : this is like textbox apart from that having some additional properties and methods which will support to open and save rtf (rich text format) files along with some formatting.
if (openFileDialog1.ShowDialog() == DialogResult.OK)
textBox1.Text = openFileDialog1.FileName;
richTextBox1.LoadFile(textBox1.Text);
saveFileDialog1.ShowDialog();
richTextBox1.SaveFile(saveFileDialog1.FileName);
Extenders :
Extenders are also controls that extend the properties of other controls. Extender is a new concept using which we can enhance the existing controls instead of providing new controls. In .net extenders are available in windows forms and also in ASP.net AJAX.
in .Net we have – error provider, tool tip and help provider.
1. Error provider : Used to display errors for existing controls in the form so that users can get the error information in a better style than a label or message box. Error provider shows an icon that can be adjusted to any corner of textbox and display the error when mouse pointer is hovered on it.
Note : Error provider can be used to validate data for a single field called as field level validation and also for the entire form called as form level validation. It has a method SETERROR() that dynamically allows user to set errors.
it adds two properties to every control. 1. Error provider 2. iconalignment 3. iconpadding
2. Tooltip : Tooltip provides help for our application controls. They are displayed when we hover the mouse pointer on a control. Using tooltip we can provide form level information ie for whole app and also for an individual control
properties : Active, isballoon, tooltipicon, tooltiptitle
3. Help provider : Providing full-fledged help when user press F1 key in the application can be done using help provider. We must prepare help with an extension .html or .chm (compiled html file) and some other format files using some utilities (but not using .net.) Using .net we can only show the help file created when we press F1
Properties : Helpnamespace – set the help file (help provider property)
helpnavigatoronhelpprovider
helpkeywordonhelpprovider
helpstringonhelpprovider
Strips :
– .net 2.0 added many new controls and also added many new capabilities to the existing controls. Some of the important new controls are
– menu strip
– tool strip
– status strip
– splitter
– property grid
– web browser and few more
Menu Strip :
– used to design modern menus
– softwares like Vista (OS), office 2007, share point etc now provide ribbons kind of interface. A menu that is shown as ribbon. Every ribbon has all its options in a better style than menu suboptions.
– one of the advantages of ribbon is we can make user explore to all menu options.
– A menu now can have a combobox, textbox accessed as simple as a control and can have images just with image property, checked, disabled etc…
– hence menustrip provides a rich user interface.
– layoutstyle is the property of menustrip to change the layout of the menu.
– dock is the property to align the menu to the currently opened form (left, right, top, bottom etc)
Toolstrip :
– to create toolbars again rich toolbars using toolstrip
– frequent actions are simplified using toolbar menu options
displaystyle (important property)
checkstate
– toostrip allows other rich controls also like combo, textbox, progressbar, toggle kind of button, text style of buttons etc leading to undoubtedly rich UI
– some important properties really make a toolstrip the most wanted contorl.
Status Strip :
Every app must have the status bar and it is the right place to show status to the user. Status strip is a new control that can again have different types of contorls like mainly label, progressbar, drop down button etc. These controls inside statusstrip are accessed again directly.
Note : Menu strip, toolstrip and statustrip are combinedly used in every windows application that we create, because they provide the required standards for an application.
Splitter :
A control that is used to split the form content like windows explorer, outlook express and now a days everywhere.
A proper use of splitter would be to consume it in between some controls and also dock the controls of either side
Every control has dock and anchor properties.
dock changes when the control is resized
anchor fix to the anchored place
Web browser :
Normally developing a web browser is a kind of project, but in .net 2.0 it is provided as a managed .net control. Earlier we used unmanaged COM browser control).
– using webbrowser we can provide navigation of intranet and internet based applications (sites) within windows forms environment.
– webbrowser supports all the browser capabilities and actions as methods and properties.
eg : webbrowser1.navigateurl(txturl.text);
webbrowser1.goback();
webbrowser1.goforward();
Property Grid :
The control that allows user to customize the behaviour at runtime. It produces a control just like property window. We can’t customize the display of properties in the grid
MDI Forms
– Multiple Document Interface Forms
– Application development of win forms will be involved with multiple forms and all these forms should have a centralized access so that user can access from the single point. This type of application development involves with SDI and MDI environment. Notepad is an example for SDI (Single Document Interface) environment where the menu, tool bar and other things are only for single document. MSWord, Excel, VS.net etc are examples of MDI environment, where the main window contains menus, toolbars etc and all other documents share the contents of main form.
– In MDI forms we create one parent from and other forms as child forms. These child forms share the contents of the parent form.
– In .net a form class that we create can be used to provide both SDI and MDI interfaces.
Steps for Creating an MDI environment
1. Start a new windows application
2. Add few forms to it like form1, form2, form3 etc
3. To implement MDI concept we need a parent form and in .net a normal form only should be converted to parent form. To do this select the form and set “IsMdiContainer” property to true. This converts the form as parent form and represents a dark gray color backgroud as the indication.
Note : In .net we can even set a form as parent at run time.
4. Add few controls that are needed generally for a parent form like menus, toolbars, status bars etc. Images, list boxes are additional controls.
5. A child form can be designated only at runtime.
Any form can act as a child form, so choose the desired form and present it as child form of parent form.
If form2 must be displayed as child form from parent form then the code goes like this.
Form2 obj = new Form2();
obj.Show();
obj.MdiParent = this; // only at runtime, this line creates the form as child
The above steps lead to an MDI concept where form1 is a parent form, form2 etc are child forms. This is the style that a project should be built with.
– MDI form can control the layout of its child forms. It has properties/methods that allow user to do it.
LAyoutMdi – this method is used to set window style or layout.
This.layoutmdi (mdilayout.tilehorizontal);
– LayoutMDI method is applicable only for MDI forms.
Questions on MDI :
1. Can a project in .net has multiple MDI forms?
2. Can we specify a form as parent form during run time?
3. Can a single form act as a parent form as well as child form?
4. Can MDI parent from act as child form for another parent form?
5. Is it compulsory that a project with MDI form should be a startup form?
6. Can we display child forms in absence of its parent form?
7. Can we have a single form as child form for two parent forms?
Class Library :
1. Start a new project by selecting “class library” as template. This time VS.Net creates a new project with one .cs file but which does not extend any other class.
Note : Class libraries will not have any Main function because they are not meant to run.
2. Prepare the class with all required members concepts etc. like variables, functions etc.
3. Build the solution and we can do this using Build menu of VS.net or right click on solution explorer and select build.
All the above 3 steps results in creation of .dll file in the bin folder of the project.
Note : Step2 – preparing classes can be repeated if the library needs many classes.
Public ClassAdd
{
int a,b;
public int c;
public void setvalues()
{
a=20;
b=30;
}
public void add()
{
c=a+b;
}
}
Consuming a class library in .net apps :
– A .net library can be consumed in any other .net app because they are language independent libraries.
– Irrespective of the language and also the type of app we can use the library.
1. Start a new project in any desired language. Say windows app type
2. Use add referece from project menu or from solution explorer references.
3. once rferred we can start using the classes by importing the required namespaces in the .dll.
4. Instantiate the classes using new and consume as per requirement.
VS.net nature is choosing an assembly as private or shared.
Note : VS.net takes the assembly as private when it is not provided from assembly folder and also when it is not loaded in GAC. That is why it copies the .dll to the current projects bin folder if it is referred from local or normal directory.
Eg : clsAdd obj = new clsadd();
obj.setvalues();
obj.add();
Assembly : In .net assemblies are the key units.
– All language compilers produce MSIL in the form of file called Assembly.
– Assembly is the distributable or deployable unit of .net
– Every assembly is divided into 2 parts
(a) Metadata – data about data
(b) MSIL – code
– Metadata is again split into 2 parts.
(a) type info – which is information about MSIL code
like – how many classes are there?
how many methods are there?
What is the signature ?
(b) Assembly info – which is information about an assembly itself.
Like – name of assembly
version of assembly
culture of assembly and many more
This part of metadata is also called as Manifest.
– Assembly is a file with an extension of either .exe or .dll only
Note : The classical .exe/.dll is different compared to .net .exe/.dll. This files need CLR to run and are executable wherever CLR is present.
– To run assemblies in windows we can just type of the .exe file name and press enter but in other OS it differs.
* Assemblies are the building blocks of an application and are logical dll’s
* In .net assemblies are self describing via metadata
* Before .net every file has another file to describe the file. .tlb contains the description of .dll. In .net .dll is only one file which contains metadata. So assemblies are self describing
* The metadata of dll can be read by runtime, programmer and also utilities like VS.net etc. The process of reading metadata from an assembly is called REFLECTION.
Without vs.net also we can prepare a .dll and use the .dll in the same manner but one should know the procedure to do it.
1. Start notepad and create a class with the member required
2. Save it and switch over to command prompt i.e. vs.net command prompt.
3. CSC /target: library demolib.cs
– result would be demolib.dll. If target is not specified it would try to create .exe assembly which needs a main function – results in error.
/ out : generates the filename as described.