EMS: Employee manager system LMS: Library management system
“Windows forms control library project template”
IIS: Internet information service ASPX: Afire server pages extension
Step1 open windows forms control library project, then design the control as required and write the logic Step2 Add an Jcon(optional),Build the project to get a DLL file. Step3 open windows forms application project and add the DLL file into the Tool Box. Obs:- A new control will be added into the Tool Box Step4 place a new control on the form add use it as per the requirement. User defined control is a class, which must be inherited either from user control class or form any exiting control Based on above statement, user defined controls are divided into two types
User Control Text box Text Text àWhen the base class name is user control, then it is called as “General User control”. When the base class name is any existing control name like text box, button etc, then it is called as “Inherited” user control”.
Open windows forms control Library project with project name login text. (Out put file is login text.Dll) Choose properties and set name = login (User defined control) (This name will be displayed in the tool box after adding the control) Lace two labels, two text boxes and a button as shown code for button1_click If (text box1.text ==”teja”&&text box2. Text==”abc”) Message box. show(“valid user”); Else Message box. show(“not a valid user”); } Adding an Icon Viewà Solution ExplorerRt click on login text Add New item Bit map and provide the name as login.bmp
user control name and BMP file names must be same. Choose properties and ht width =16 and height=16 Design the bitmap as required Choose the properties of login.bmp file and set build action= embedded resource.
Login text.dll will be created under F:/0194/ Login text/ Bin/debug folder Open WFAP Open tool boxàRt Click inside of tool boxàadd tapà gire the name hy controls Open tool boxàRt Click inside of my controls tabàchoose itemsàbrowseàlogin text. Dll (or) Drag login text. Dll file into Tool box my control tab
A New control will be added with the name login Place a login control on to the form
I.e, In above example it is not possible to change the text of labels, text boxes or button
A =10 Set Property B=AGET Property
Data type variable; Public data type pName { Set { Variable = value; } Get { Return variable; } }
Open windows forms control Library project with project name scrollable control Place a label control. Place a timer with enabled = true Place one more timer with enabled= false . Code for hmer1_tick { Label1.Top= Label1.Top-5;(It will scroll upwards) If(Label1.Top<0) { timer 1.Enabled = false; timer 2.Enabled = True; } } àCode for timer2-Tick { Label1.Top=Label1.top+5); If(Label1.top>350) { Timer1.enabled=true; Timer2.enabled=false; } } àcode in GD(Initialize component) //LtextàLabel1.textàString Public string L Text { Set{Label1.Text=value;} Get{return Label1.Text;} } //LFontàLabel1.FontàFont Public Font LFont (or) Public Font1 Font { Set{Label1.Font=value;} Get{return Label1.Font;} } //LBcoloràLabel1.Back Coloràcolor Public color LB color { Set{Label1.Back clor=value;} Get{return Label1.back color;} } //LSpeedàTimer. Intervalàint Public int LSpeed { Set { Timer1.Interval=value; Timer2.Interval=value; } Get {return timer1.interval;} } Build the project(Build menuàbuild solution)
Scrollable control.dll is created under D:\c194\Scrollable control\Bin\Debug Folder With a new control named “User control1”.
àDrag scrollable control.DLL into tool boxàMy controls tab àThen a new control with name user control 1 will be added into the tool box place this control on the form and check Ltext, Lfont, LB color and Lspeed properties.
IN UC Text box-----40 properties Text_______1 properties 41 properties
User control Test Test =” ABC” Generally inherited user control’s class declaration will be as follows Public partial class test: Text box { } In inherited user controls only application logic allowed but placing some other controls are not allowed
Developing a user defined text box with a new property called as input type If input type is A or a ,then text box need to accept only Alphabets If input type is D or D, then text box need to be accept only digits. If input type is All then text box need to accept all characters. open windows forms control library project with project name UDT. Open code window by pressing f7(don’t double click on the form to open code window) Change the class declaration as follows Public partial class user defined control: Text box code in GD String S =”ALL”;//This is the default value for input type property. Public user control() Public String Input type { Set{S=Value;} Get{return S} }
Private void user control – key press(--) { If(s==”A”// S ==”a”) { If(e.kdy char>=’A’&& e. key char=’Z’) //e.key char>=’a’ && e. key char=’Z’)
else
Cancels the Key stoke } If(S==”D”\\S==d) { If(e.key char>=’o’&& e.key char<=’9’)
else
} Build the project(Build menuà Build solution)
UDT.DLL will be created under E:\c194\UDT\bin\debug folder Open windows forms application project àDrag UDT.DLL into tool boxàMy controls tab, then a new control will be added with the name user control Design the form As shown Execute the project and check either text boxes are accepting proper input or not.
A call back procedure is also called user defined events
Syntax: Public delegate void delegate name(or) Dname()
Syntax Public event D Nam Event name; Step3 :Raise event or call the event Syntax: Erent name() Step4: Define the event(Write the body) Prirate void control name enent name() { Logic; }
open windows control library with project name UDE Place button Code in GD Step1: Public d delegate void D name(); Step2: Public event D name Abc; Code for Button1-click Message box. show(“from uses control”) Stpe3: Abc(); Build the project(Build menuà build solution) UDE.Dll will be crated under E:\c194\UDE\bin\debug àopen windows forms application project
Tabà place an added control on the form (user control 1) àCode for user control ABC event Message Box. show(“from form”);
You liked the article?
Like : 0
Vote for difficulty
Current difficulty (Avg): Medium
1/15
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.
Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox