SlideShare uma empresa Scribd logo
1 de 5
Baixar para ler offline
Demo Projects:
• Employee Information Form (Using advance controls)
What will you learn?
• Using following controls:
o Masked Textbox
o Multiline Textbox
o ComboBox, ListBox
o DateTimePicker
o NumericUpDown
o RadioButton
• Adding Items to ComboBox
Dynamically
• Enabling Autocomplete
• Getting Selected items form ComboBox, ListBox and CheckBoxList
• Clearing or resetting all these controls to default values.
Windows Forms for Beginners
www.dotnetvideotutorial.com
Employee Information Form (Using advance controls)
Using following controls:
Textbox
Multiline Textbox
ListBox, CheckBoxList
NumericUpDown
Adding Items to ComboBox, ListBox and CheckBoxList Statically and
Autocomplete feature in ComboBox
Getting Selected items form ComboBox, ListBox and CheckBoxList
Clearing or resetting all these controls to default values.
Bhushan Mulmule
bhushan.mulmule@gmail.com
www.dotnetvideotutorial.com
Windows Forms for Beginners
Part 3
Statically and
Getting Selected items form ComboBox, ListBox and CheckBoxList
Bhushan Mulmule
bhushan.mulmule@gmail.com
www.dotnetvideotutorial.com
Windows Forms for Beginners
www.dotnetvideotutorial.com
Project 1: Employee Information Form
Using Advance Controls
Step 1: Design UI: Refer instructions below for details
TextBox:
Name: txtAddress
MultiLine: True
ComboBox:
Name: cmbCity
Items: Nagpur, Pune,
Mumbai, Banglore, Nanded
,Nainital.
AutoCompliteSource:
ListItems
AutoCompliteMode:
Suggest
ListBox:
Name: lstState
DateTimePicker:
Name: dtpDOB
Format: Custom
CustomFormat: dd/MM/yyyy
NumbericUpDown:
Name: nudAge
Minimum: 18
Maximum: 60
RadioButtons:
Name: radMale, radFemale
CheckBoxList:
Name: chkLstHobbies
Items: Singing, Dancing,
Panting, Shopping,
Gardening, Swimming,
Sleeping
MultiColumn: True
CheckOnClick: True
TextBox:
Name: txtDetails
MultiLine: True
TextBox:
Name: txtName
3 Buttons:
Name: btnReset, btnOK,
btnExit.
Text: Reset, OK, Exit
MaskTextBox:
Name: mskTxtEmpNo
Mask: 0000
www.dotnetvideotutorial.com
Instructions:
• MaskedTextBox allows defining format for input using Mask property.
o Mask = 0000: To make it compulsory to user to enter 4 digit employee
number.
• Multiline property of textbox need to be set to true in order to enter multiple
lines in textbox
• ComboBox allows user to select item from predefined list
o Items property holds multiple items. When you will click on Items
property Collection Editor Window will open where you can add multiple
items (one item per line)
o AutoCompleteSource and AutoCompleteMode enables AutoComplete
feature of combobox. So that user can type in ComboBox and can select
item from matching suggestion list.
• ListBox is same as ComboBox except it displays multiple items as list.
o Items property can be used to populate control same as ComboBox.
o In this example we are populating it dynamically by writing function
PopulateStates and calling it from Form_Load Event
• DateTimePicker enables user to select date visually.
o Format property provides various predefined formats for date
o CustomFormat property allows to define custom format.
o To use CustomFormat; Format property need to set to CustomFormat
• NumericUpdown enables user to select numeric value from predefined range
o Minimum and Maximum properties need to be set
• Radio buttons for gender has to be in group box to specify that they are in same
group and only one should get selected out of them.
• CheckBoxList allows to select multiple items easily from predefined list
o We can populate it statically using item property or dynamically using
code as for ListBox.
o We will populate it using items property
o We will also
• Details textbox is nothing but textbox with multiline property set to true.
o To show all the details on this textbox first we will collect all the
information in string and then will assign it to details textbox.
www.dotnetvideotutorial.com
o Note: Strings are immutable and creates new object with every
concatenation. So this can be done better using StringBuilder Class.
(When you need to concatenate string number of times you should use
StringBuilder Class) Read about it and try to implement same thing using
StringBuilder class after finishing this walkthrough.
Step 3: Add event handlers for buttons
1. Double Click on Form to go to code window. Create function PopulateStates
outside form_load event
private void PopulateStates()
{
lstStates.Items.Add("Maharashtra");
lstStates.Items.Add("MP");
lstStates.Items.Add("Punjab");
lstStates.Items.Add("Karnataka");
lstStates.Items.Add("Goa");
}
2. Call PopulateSates from Form_Load Event
private void frmEmployeeDetails_Load(object sender, EventArgs e)
{
PopulateStates();
}
3. Double click on OK button:
private void btnOK_Click(object sender, EventArgs e)
{
string details;
details = "EmpNo: " + mskTxtEmpNo.Text;
details += "rnName: " + txtName.Text;
details += "rnAddress: " + txtAddress.Text;
details += "rnCity: " + cmbCity.SelectedItem;
details += "rnState: " + lstState.SelectedItem;
details += "rnDOB: " + dtpDOB.Value.ToShortDateString();
details += "rnAge: " + numAge.Value.ToString();
string gender = radMale.Checked ? "Male" : "Female";
details += "rnGender: " + gender;
www.dotnetvideotutorial.com
string hobbies="";
foreach (string h in chkLstHobbies.CheckedItems)
hobbies += h + "rnt";
details += "rnHobbies: " + hobbies;
txtDetails.Text = details;
}
4. Reset button code:
private void btnReset_Click(object sender, EventArgs e)
{
mskTxtEmpNo.Text = "";
txtName.Text = "";
txtAddress.Text = "";
cmbCity.SelectedIndex = -1;
lstState.SelectedIndex = -1;
dtpDOB.Value = DateTime.Now;
numAge.Value = numAge.Minimum;
radMale.Checked = false;
radFemale.Checked = false;
//unchek all items
for (int i = 0; i < chkLstHobbies.Items.Count; i++)
chkLstHobbies.SetItemChecked(i, false);
//removes blue selection
chkLstHobbies.ClearSelected();
txtDetails.Text = "";
mskTxtEmpNo.Focus();
}

Mais conteúdo relacionado

Mais procurados (20)

06 win forms
06 win forms06 win forms
06 win forms
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinForm
 
Vs c# lecture1
Vs c# lecture1Vs c# lecture1
Vs c# lecture1
 
Vs c# lecture3
Vs c# lecture3Vs c# lecture3
Vs c# lecture3
 
Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)Windows form application_in_vb(vb.net --3 year)
Windows form application_in_vb(vb.net --3 year)
 
Controls events
Controls eventsControls events
Controls events
 
Vs c# lecture2
Vs c# lecture2Vs c# lecture2
Vs c# lecture2
 
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.154.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
 
Spf chapter10 events
Spf chapter10 eventsSpf chapter10 events
Spf chapter10 events
 
Vs c# lecture5
Vs c# lecture5Vs c# lecture5
Vs c# lecture5
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Introduction to Visual Basic
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
 
Part 12 built in function vb.net
Part 12 built in function vb.netPart 12 built in function vb.net
Part 12 built in function vb.net
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6
 
Vs c# lecture4
Vs c# lecture4Vs c# lecture4
Vs c# lecture4
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
 
Active x control
Active x controlActive x control
Active x control
 
Intake 38 8
Intake 38 8Intake 38 8
Intake 38 8
 
Image contro, and format functions in vb
Image contro, and format functions in vbImage contro, and format functions in vb
Image contro, and format functions in vb
 

Destaque

Destaque (6)

Windows Forms For Beginners Part - 2
Windows Forms For Beginners Part - 2Windows Forms For Beginners Part - 2
Windows Forms For Beginners Part - 2
 
c#.Net Windows application
c#.Net Windows application c#.Net Windows application
c#.Net Windows application
 
Ch2 ar
Ch2 arCh2 ar
Ch2 ar
 
ASP
ASPASP
ASP
 
Asp .net web form fundamentals
Asp .net web form fundamentalsAsp .net web form fundamentals
Asp .net web form fundamentals
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
 

Semelhante a Windows Forms For Beginners Part - 3

Combo box and List box in VB.Net.ppt
Combo box and List box in VB.Net.pptCombo box and List box in VB.Net.ppt
Combo box and List box in VB.Net.pptUjwala Junghare
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls objectallenbailey
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfeyebolloptics
 
C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesSami Mut
 
Paste Only Plain Text in RichTextBox Control using Visual Basic.Net
Paste Only Plain Text in RichTextBox Control using Visual Basic.NetPaste Only Plain Text in RichTextBox Control using Visual Basic.Net
Paste Only Plain Text in RichTextBox Control using Visual Basic.NetDaniel DotNet
 
CheckBox In C#.pptx
CheckBox In C#.pptxCheckBox In C#.pptx
CheckBox In C#.pptxSlemanIsmail
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshopdhi her
 
Web forms and html lecture Number 4
Web forms and html lecture Number 4Web forms and html lecture Number 4
Web forms and html lecture Number 4Mudasir Syed
 

Semelhante a Windows Forms For Beginners Part - 3 (20)

Combo box and List box in VB.Net.ppt
Combo box and List box in VB.Net.pptCombo box and List box in VB.Net.ppt
Combo box and List box in VB.Net.ppt
 
GWT Widgets
GWT WidgetsGWT Widgets
GWT Widgets
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
Winforms
WinformsWinforms
Winforms
 
3.5 the controls object
3.5   the controls object3.5   the controls object
3.5 the controls object
 
GUI -THESIS123
GUI -THESIS123GUI -THESIS123
GUI -THESIS123
 
Write a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdfWrite a program that mimics the operations of several vending machin.pdf
Write a program that mimics the operations of several vending machin.pdf
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
 
Unit2
Unit2Unit2
Unit2
 
C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slides
 
Mobile Application Development class 007
Mobile Application Development class 007Mobile Application Development class 007
Mobile Application Development class 007
 
Paste Only Plain Text in RichTextBox Control using Visual Basic.Net
Paste Only Plain Text in RichTextBox Control using Visual Basic.NetPaste Only Plain Text in RichTextBox Control using Visual Basic.Net
Paste Only Plain Text in RichTextBox Control using Visual Basic.Net
 
CheckBox In C#.pptx
CheckBox In C#.pptxCheckBox In C#.pptx
CheckBox In C#.pptx
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
 
Web forms and html lecture Number 4
Web forms and html lecture Number 4Web forms and html lecture Number 4
Web forms and html lecture Number 4
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
Qtp day 3
Qtp day 3Qtp day 3
Qtp day 3
 
Chapter - 6.pptx
Chapter - 6.pptxChapter - 6.pptx
Chapter - 6.pptx
 
5. combobox
5. combobox5. combobox
5. combobox
 

Mais de Bhushan Mulmule

Mais de Bhushan Mulmule (12)

Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQuery
 
NInject - DI Container
NInject - DI ContainerNInject - DI Container
NInject - DI Container
 
Dependency injection for beginners
Dependency injection for beginnersDependency injection for beginners
Dependency injection for beginners
 
Understanding Interfaces
Understanding InterfacesUnderstanding Interfaces
Understanding Interfaces
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Inheritance
InheritanceInheritance
Inheritance
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Methods
MethodsMethods
Methods
 
Arrays, Structures And Enums
Arrays, Structures And EnumsArrays, Structures And Enums
Arrays, Structures And Enums
 
Flow Control (C#)
Flow Control (C#)Flow Control (C#)
Flow Control (C#)
 
Getting started with C# Programming
Getting started with C# ProgrammingGetting started with C# Programming
Getting started with C# Programming
 
Overview of .Net Framework 4.5
Overview of .Net Framework 4.5Overview of .Net Framework 4.5
Overview of .Net Framework 4.5
 

Último

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Windows Forms For Beginners Part - 3

  • 1. Demo Projects: • Employee Information Form (Using advance controls) What will you learn? • Using following controls: o Masked Textbox o Multiline Textbox o ComboBox, ListBox o DateTimePicker o NumericUpDown o RadioButton • Adding Items to ComboBox Dynamically • Enabling Autocomplete • Getting Selected items form ComboBox, ListBox and CheckBoxList • Clearing or resetting all these controls to default values. Windows Forms for Beginners www.dotnetvideotutorial.com Employee Information Form (Using advance controls) Using following controls: Textbox Multiline Textbox ListBox, CheckBoxList NumericUpDown Adding Items to ComboBox, ListBox and CheckBoxList Statically and Autocomplete feature in ComboBox Getting Selected items form ComboBox, ListBox and CheckBoxList Clearing or resetting all these controls to default values. Bhushan Mulmule bhushan.mulmule@gmail.com www.dotnetvideotutorial.com Windows Forms for Beginners Part 3 Statically and Getting Selected items form ComboBox, ListBox and CheckBoxList Bhushan Mulmule bhushan.mulmule@gmail.com www.dotnetvideotutorial.com Windows Forms for Beginners
  • 2. www.dotnetvideotutorial.com Project 1: Employee Information Form Using Advance Controls Step 1: Design UI: Refer instructions below for details TextBox: Name: txtAddress MultiLine: True ComboBox: Name: cmbCity Items: Nagpur, Pune, Mumbai, Banglore, Nanded ,Nainital. AutoCompliteSource: ListItems AutoCompliteMode: Suggest ListBox: Name: lstState DateTimePicker: Name: dtpDOB Format: Custom CustomFormat: dd/MM/yyyy NumbericUpDown: Name: nudAge Minimum: 18 Maximum: 60 RadioButtons: Name: radMale, radFemale CheckBoxList: Name: chkLstHobbies Items: Singing, Dancing, Panting, Shopping, Gardening, Swimming, Sleeping MultiColumn: True CheckOnClick: True TextBox: Name: txtDetails MultiLine: True TextBox: Name: txtName 3 Buttons: Name: btnReset, btnOK, btnExit. Text: Reset, OK, Exit MaskTextBox: Name: mskTxtEmpNo Mask: 0000
  • 3. www.dotnetvideotutorial.com Instructions: • MaskedTextBox allows defining format for input using Mask property. o Mask = 0000: To make it compulsory to user to enter 4 digit employee number. • Multiline property of textbox need to be set to true in order to enter multiple lines in textbox • ComboBox allows user to select item from predefined list o Items property holds multiple items. When you will click on Items property Collection Editor Window will open where you can add multiple items (one item per line) o AutoCompleteSource and AutoCompleteMode enables AutoComplete feature of combobox. So that user can type in ComboBox and can select item from matching suggestion list. • ListBox is same as ComboBox except it displays multiple items as list. o Items property can be used to populate control same as ComboBox. o In this example we are populating it dynamically by writing function PopulateStates and calling it from Form_Load Event • DateTimePicker enables user to select date visually. o Format property provides various predefined formats for date o CustomFormat property allows to define custom format. o To use CustomFormat; Format property need to set to CustomFormat • NumericUpdown enables user to select numeric value from predefined range o Minimum and Maximum properties need to be set • Radio buttons for gender has to be in group box to specify that they are in same group and only one should get selected out of them. • CheckBoxList allows to select multiple items easily from predefined list o We can populate it statically using item property or dynamically using code as for ListBox. o We will populate it using items property o We will also • Details textbox is nothing but textbox with multiline property set to true. o To show all the details on this textbox first we will collect all the information in string and then will assign it to details textbox.
  • 4. www.dotnetvideotutorial.com o Note: Strings are immutable and creates new object with every concatenation. So this can be done better using StringBuilder Class. (When you need to concatenate string number of times you should use StringBuilder Class) Read about it and try to implement same thing using StringBuilder class after finishing this walkthrough. Step 3: Add event handlers for buttons 1. Double Click on Form to go to code window. Create function PopulateStates outside form_load event private void PopulateStates() { lstStates.Items.Add("Maharashtra"); lstStates.Items.Add("MP"); lstStates.Items.Add("Punjab"); lstStates.Items.Add("Karnataka"); lstStates.Items.Add("Goa"); } 2. Call PopulateSates from Form_Load Event private void frmEmployeeDetails_Load(object sender, EventArgs e) { PopulateStates(); } 3. Double click on OK button: private void btnOK_Click(object sender, EventArgs e) { string details; details = "EmpNo: " + mskTxtEmpNo.Text; details += "rnName: " + txtName.Text; details += "rnAddress: " + txtAddress.Text; details += "rnCity: " + cmbCity.SelectedItem; details += "rnState: " + lstState.SelectedItem; details += "rnDOB: " + dtpDOB.Value.ToShortDateString(); details += "rnAge: " + numAge.Value.ToString(); string gender = radMale.Checked ? "Male" : "Female"; details += "rnGender: " + gender;
  • 5. www.dotnetvideotutorial.com string hobbies=""; foreach (string h in chkLstHobbies.CheckedItems) hobbies += h + "rnt"; details += "rnHobbies: " + hobbies; txtDetails.Text = details; } 4. Reset button code: private void btnReset_Click(object sender, EventArgs e) { mskTxtEmpNo.Text = ""; txtName.Text = ""; txtAddress.Text = ""; cmbCity.SelectedIndex = -1; lstState.SelectedIndex = -1; dtpDOB.Value = DateTime.Now; numAge.Value = numAge.Minimum; radMale.Checked = false; radFemale.Checked = false; //unchek all items for (int i = 0; i < chkLstHobbies.Items.Count; i++) chkLstHobbies.SetItemChecked(i, false); //removes blue selection chkLstHobbies.ClearSelected(); txtDetails.Text = ""; mskTxtEmpNo.Focus(); }