Bca 5th Sem .Net 3rd Unit
Bca 5th Sem .Net 3rd Unit
.NET Tools:
1. Visual Studio
- Description: Yeh ek primary tool hai .NET development ke liye. Isme debugging, testing,
version control, aur deployment jaisi saari suvidhaayein milti hain.
- Features:
- Bugs find karne aur fix karne ka option hota hai (Integrated Debugger).
- Description: Yeh ek lightweight code editor hai, jisme .NET ke liye C# extension use kiya
ja sakta hai. Cross-platform support karta hai.
- Features:
- Description: .NET CLI command line se projects create, build, run, aur publish karne ke
liye use hota hai.
- Commands:
4. NuGet
- Description: NuGet ek package manager hai .NET ke liye. Iske through aap third-party
libraries ko apne project mein add kar sakte hain.
- Command:
- `dotnet add package PackageName` - Yeh command package add karne ke liye use
hota hai.
5. ReSharper
- Description: Yeh ek productivity tool hai jisse aap code refactor kar sakte hain, analysis
kar sakte hain, aur testing mein madad milti hai.
- Key Features:
- Description: Entity Framework ek Object Relational Mapper hai jo .NET mein database
ke saath interact karne mein madad karta hai.
- Commands:
7. Fiddler
- Description: Fiddler ek tool hai jo network traffic ko inspect karne ke liye use hota hai.
Web applications ka debugging aur performance analysis mein help karta hai.
8. Postman
- Description: APIs ko test karne ke liye use hota hai. HTTP requests ko easily create aur
test kar sakte hain.
- Description:
11. Docker
- Description: Docker ko use karke aap apne .NET apps ko containerize kar sakte hain
taaki wo kisi bhi environment mein deploy ho sakein. Yeh deployment ko easy aur
consistent banata hai.
12. Kudu
- Description: Yeh Azure App Services ka deployment engine hai jisse aap Git
deployments manage kar sakte hain.
14. SonarQube
- Description: Code quality analyze karta hai, bugs aur vulnerabilities detect karta hai,
aur CI/CD pipelines mein integrate hota hai.
16. PowerShell
- Description: PowerShell scripting aur automation ke liye use hota hai. Aap deployment
aur administrative tasks automate kar sakte hain.
17. MSBuild
- Description: MSBuild .NET projects ko build karne ke liye default tool hai.
18. LINQPad
- Description: LINQPad ek powerful tool hai jisse aap databases ko interactively query
kar sakte hain LINQ se, bina poora project banaye.
Summary
- Automation: PowerShell.
Yeh saare tools aapko .NET project ke lifecycle mein madad karte hain - development se
lekar deployment, testing, aur maintenance tak. Har tool ko aap apni zaroorat ke hisaab se
choose kar sakte hain.
Control Class:
Control class .NET mein Windows Forms applications ke liye ek base class hai, jo sabse
zyada visual elements ko handle karti hai. Iska use har tarah ke UI components, jaise
buttons, labels, textboxes, etc., ko create aur manage karne mein hota hai. Yeh
`System.Windows.Forms` namespace mein milti hai aur saari controls ke liye properties,
methods, aur events provide karti hai.
Namespace
- `System.Windows.Forms`
Key Characteristics
- Yeh position, size, color, aur event handling jaise features provide karti hai.
- Button, TextBox, Label, ListBox jaise saare controls `Control` class se inherit karte hain.
`Control` class mein kai properties hain jisse aap controls ka appearance aur behavior
manage kar sakte hain:
```csharp
control.Name = "myControl";
```
```csharp
```
3. Location: Control ki (x, y) coordinates ko specify karta hai jo container ke hisaab se hoti
hain.
```csharp
```
```csharp
```
```csharp
myButton.BackColor = Color.LightBlue;
```
```csharp
myLabel.ForeColor = Color.Red;
```
7. Enabled: Yeh batata hai ki control user input ko respond kar sakta hai ya nahi.
```csharp
```
```csharp
```
9. Anchor aur Dock: Control ka size kaise resize ho usko control karta hai.
```csharp
```
Common Methods
`Control` class mein kuch common methods bhi hain jisse aap controls ko manage aur
interact kar sakte hain:
```csharp
myControl.Show();
myControl.Hide();
```
```csharp
myTextBox.Focus();
```
```csharp
myPanel.Invalidate();
```
4. BringToFront() aur SendToBack(): Z-order adjust karta hai (matlab controls ke upar ya
neeche dikhne ka order).
```csharp
```
Common Events
`Control` class mein kai events hain jisse aap user actions par respond kar sakte hain:
1. Click: Jab control par click hota hai toh trigger hota hai.
```csharp
2. MouseHover: Jab mouse pointer control ke upar hover karta hai toh trigger hota hai.
```csharp
```
3. KeyPress: Jab control ke upar focus ho aur koi key press ki jaye toh trigger hota hai.
```csharp
```
```csharp
```
Derived Classes
Yeh ek example hai jisme hum Control class aur derived types ko use karke ek simple
Windows Forms application bana rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
this.Controls.Add(myButton);
this.Controls.Add(myTextBox);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
Summary
- Control class Windows Forms mein almost saare UI components ke liye base class hai.
- Yeh shared functionality provide karti hai jaise positioning, size, event handling, aur
visibility.
- Windows Forms ke saare controls (`Button`, `TextBox`, `Label`, etc.) `Control` class
se inherit karte hain, jiska matlab hai ki yeh saari properties, methods, aur events use kar
sakte hain.
Yeh Control class ek important foundation hai Windows Forms applications banane ke
liye, kyunki isse aapko ek common framework milta hai sabhi UI components ko control
karne ka.
TextBox:
TextBox ek Windows Forms control hai jiska use user input lene ya text display karne ke
liye hota hai. Yeh sabse common controls mein se ek hai, aur aap ise plain text, numbers,
password, etc. ke liye use kar sakte hain.
- Namespace: `System.Windows.Forms`
- Common Use Cases: User se naam, address, comments, password wagaira lena.
1. Text:
- `Text` property mein `TextBox` ka andar ka text store hota hai.
- Example:
```csharp
```
2. MaxLength:
- Isme aap maximum characters set kar sakte hain jo user enter kar sakta hai.
- Example:
```csharp
myTextBox.MaxLength = 50; // User sirf 50 characters tak enter kar sakta hai.
```
3. Multiline:
- Agar `true` set karte hain, toh `TextBox` mein multiple lines mein text display ho sakta
hai.
- Example:
```csharp
myTextBox.Multiline = true;
```
4. PasswordChar:
- Example:
```csharp
5. ReadOnly:
- Agar `true` set ho, toh `TextBox` mein text edit nahi kar sakte, sirf copy kar sakte hain.
- Example:
```csharp
myTextBox.ReadOnly = true;
```
6. ScrollBars:
- Scroll bars add karta hai `TextBox` mein agar multiline ho aur content zyada ho.
- Options:
- `ScrollBars.None` (default)
- `ScrollBars.Horizontal`
- `ScrollBars.Vertical`
- `ScrollBars.Both`
- Example:
```csharp
myTextBox.ScrollBars = ScrollBars.Vertical;
```
7. WordWrap:
- Yeh decide karta hai ki text wrap ho ya nahi jab woh edge tak pahunch jaye (sirf jab
Multiline `true` ho).
- Example:
```csharp
myTextBox.WordWrap = true;
```
1. Clear():
- Example:
```csharp
myTextBox.Clear();
```
2. AppendText():
- Current text ke end mein kuch aur text add karta hai.
- Example:
```csharp
```
1. TextChanged:
- Jab bhi `TextBox` ka text change ho, toh yeh event trigger hota hai.
- Example:
```csharp
```
2. KeyPress:
- Jab `TextBox` par focus ho aur koi key press ho, tab trigger hota hai.
- Example:
```csharp
e.Handled = true; // Sirf letters, digits, aur control keys allow honge.
```
- Enter event tab trigger hota hai jab `TextBox` focus mein aaye.
- Leave event tab trigger hota hai jab `TextBox` focus se bahar jaye.
- Example:
```csharp
```
Yahan ek example hai jisme hum `TextBox` use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myTextBox.MaxLength = 100;
myTextBox.Multiline = true;
myTextBox.ScrollBars = ScrollBars.Vertical;
this.Controls.Add(myTextBox);
this.Controls.Add(myButton);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
}
```
Is example mein:
Summary
- TextBox control use hota hai user input lene ya text display karne ke liye.
- Properties jaise Text, Multiline, PasswordChar aur events jaise TextChanged, KeyPress
isko versatile banate hain.
TextBox ek flexible control hai jo Windows Forms mein kaafi tarah ke text-based input ke
liye suitable hai.
RichTextBox Windows Forms mein ek advanced version hai TextBox ka, jo formatted text
display aur edit karne ki ability deta hai. Yeh TextBox se zyada powerful hai, kyunki ismein
text styling, formatting, images, aur multiple fonts use kiye ja sakte hain.
RichTextBox ka Overview
- Namespace: `System.Windows.Forms`
- Purpose: Rich text editing aur formatted text display karne ke liye.
- Common Use Cases: User ko formatted content type karne dena, jaise ki notes, reports,
ya email editor. Iska use tab hota hai jab plain text se kuch zyada control chahiye ho.
- Rich Text Format (RTF) ko get/set karta hai. Yeh text ko formatting ke saath store karta
hai.
- Example:
```csharp
```
2. Text:
- Example:
```csharp
```
3. SelectionFont:
- Example:
```csharp
```
4. SelectionColor:
```csharp
```
5. SelectionBackColor:
- Example:
```csharp
```
6. DetectUrls:
- URLs ko detect karke unko clickable links mein convert karta hai.
- Example:
```csharp
```
7. Multiline:
- TextBox ki tarah, Multiline property se aap decide kar sakte hain ki ek se zyada lines
likhne di jayein ya nahi.
- Example:
```csharp
myRichTextBox.Multiline = true;
```
8. ScrollBars:
- Scroll bars add karta hai jab content bohot bada ho.
- Example:
```csharp
```
1. AppendText():
- Example:
```csharp
```
2. LoadFile():
- Example:
```csharp
myRichTextBox.LoadFile("file.rtf", RichTextBoxStreamType.RichText);
```
3. SaveFile():
- `RichTextBox` ka content save karta hai ek file mein.
- Example:
```csharp
myRichTextBox.SaveFile("output.rtf", RichTextBoxStreamType.RichText);
```
1. TextChanged:
- Jab `RichTextBox` ka content change ho jaye, toh yeh event trigger hota hai.
- Example:
```csharp
```
2. LinkClicked:
- Jab `RichTextBox` mein koi link click ho, toh yeh event trigger hota hai.
- Example:
```csharp
myRichTextBox.LinkClicked += new
LinkClickedEventHandler(MyRichTextBox_LinkClicked);
private void MyRichTextBox_LinkClicked(object sender, LinkClickedEventArgs e)
```
Yeh ek example hai jisme hum ek RichTextBox ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myRichTextBox.SelectionColor = Color.Blue;
this.Controls.Add(myRichTextBox);
this.Controls.Add(myButton);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
}
```
Is example mein:
Summary
- RichTextBox ek advanced version hai `TextBox` ka, jo formatted text display aur edit
karne ke liye use hota hai.
- Ismein aap text ko style kar sakte hain jaise bold, italic, underline, different fonts, aur
colors use kar sakte hain.
- Iska use tab hota hai jab aapko plain text se zyada control chahiye, jaise ki notes editor,
rich comments, ya email formatting.
RichTextBox ek powerful control hai jo Windows Forms mein advanced text formatting
features provide karta hai, jisse user ka experience aur bhi rich ho jata hai.
Label: control Windows Forms mein ek simple yet useful control hai jo text display karne
ke liye use hota hai. Yeh static text ko show karne mein help karta hai, jise user directly edit
nahi kar sakta. Labels ka use instructions, titles, headings, aur information show karne ke
liye hota hai.
Label Control ka Overview
- Namespace: `System.Windows.Forms`
- Purpose: Text display karne ke liye jisse user edit nahi kar sakta.
- Common Use Cases: UI mein kisi input field ke liye description, instructions ya phir static
text show karne ke liye.
1. Text:
- Yeh `Label` ke andar display hone wala text set ya get karta hai.
- Example:
```csharp
```
2. Font:
- Example:
```csharp
```
3. ForeColor:
- Example:
```csharp
myLabel.ForeColor = Color.Blue;
```
4. BackColor:
- Example:
```csharp
myLabel.BackColor = Color.LightGray;
```
5. AutoSize:
- Agar `true` set ho, toh label apne content ke hisaab se automatically adjust ho jata hai.
- Example:
```csharp
```
6. TextAlign:
- Example:
```csharp
```
7. BorderStyle:
- Label ke border ka style set karta hai. Options hain `None`, `FixedSingle`, aur
`Fixed3D`.
- Example:
```csharp
myLabel.BorderStyle = BorderStyle.FixedSingle;
```
Labels ke saath methods zyada nahi hain kyunki unka kaam sirf text display karna hota hai,
lekin kuch useful methods hain:
1. Refresh():
- Example:
```csharp
myLabel.Refresh();
```
Labels ke events limited hain kyunki user directly unhe interact nahi karta, lekin kuch
events hain jo useful ho sakte hain:
1. Click:
- Jab user label par click karta hai toh yeh event trigger hota hai.
- Example:
```csharp
MessageBox.Show("Label clicked!");
```
- MouseEnter event tab trigger hota hai jab mouse pointer label par aata hai.
- MouseLeave event tab trigger hota hai jab mouse pointer label se bahar jata hai.
- Example:
```csharp
```
Yahan ek example hai jisme hum Label control use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myLabel.AutoSize = true;
this.Controls.Add(myLabel);
this.Controls.Add(myTextBox);
this.Controls.Add(myButton);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- Label ko use kiya gaya hai instruction display karne ke liye (`Enter your name:`).
- Jab user Button pe click karega, toh label ka text change ho jayega user ke naam ke saath.
Summary
- Label control ek simple control hai jo text display karne ke liye use hota hai.
- Yeh user ko instructions, titles, ya fixed information dikhane mein help karta hai.
- Properties jaise Text, Font, ForeColor, BackColor aur AutoSize isko customize karne mein
madad karti hain.
- Yeh user input se interact nahi hota, lekin events jaise Click aur MouseEnter use ho sakte
hain.
Labels ka use UI mein user ko guide karne, information dene, ya kisi input field ko describe
karne ke liye hota hai, aur yeh Windows Forms mein kaafi common aur important element
hai.
Link Labels:
LinkLabel Windows Forms mein ek special type ka Label hai, jo hyperlinks ko support karta
hai. Yeh ek label ke jaisa hi hota hai, lekin text ko ek clickable link ke roop mein show karta
hai. Yeh useful hota hai jab aapko application mein web links ya kisi internal function ko
trigger karne ki zaroorat ho.
- Namespace: `System.Windows.Forms`
- Purpose: Hyperlink text ko display aur handle karne ke liye. Jab user link pe click karta hai
toh koi specific action perform hota hai, jaise web browser open karna ya application ke
kisi function ko execute karna.
- Common Use Cases: Documentation ke link dikhana, "Forgot Password" option provide
karna, ya kisi specific web page par navigate karna.
Common Properties of LinkLabel
1. Text:
- Link label mein display hone wala text set karta hai.
- Example:
```csharp
```
2. LinkColor:
- Yeh property link ka color set karti hai jab wo normal state mein ho.
- Example:
```csharp
myLinkLabel.LinkColor = Color.Blue;
```
3. VisitedLinkColor:
- Jab link ko click kar liya jaye, tab dikhne wala color set karta hai.
- Example:
```csharp
myLinkLabel.VisitedLinkColor = Color.Purple;
```
4. ActiveLinkColor:
- Jab link par mouse click ho raha ho tab jo color dikhaye, wo set karta hai.
- Example:
```csharp
myLinkLabel.ActiveLinkColor = Color.Red;
```
5. Links:
- Yeh property multiple links ko define karne ke liye use hoti hai agar ek `LinkLabel` mein
multiple parts clickable ho. Isme aap starting index aur length specify kar sakte hain.
- Example:
```csharp
```
1. LinkClicked:
- Jab user link par click kare, toh yeh event trigger hota hai.
- Iska use kisi website ko open karne, ya internal function call karne ke liye hota hai.
- Example:
```csharp
myLinkLabel.LinkClicked += new
LinkLabelLinkClickedEventHandler(MyLinkLabel_LinkClicked);
}
```
Ek example jisme hum LinkLabel ka use kar rahe hain taaki ek web link par navigate kar
sakein:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myLinkLabel.AutoSize = true;
myLinkLabel.LinkColor = Color.Blue;
myLinkLabel.VisitedLinkColor = Color.Purple;
// LinkClicked event handle karte hain
myLinkLabel.LinkClicked += new
LinkLabelLinkClickedEventHandler(MyLinkLabel_LinkClicked);
this.Controls.Add(myLinkLabel);
System.Diagnostics.Process.Start("https://www.google.com");
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- LinkLabel banaya gaya hai jo text "Click here to visit Google" show karta hai.
- Jab user link pe click karega, toh `https://www.google.com` browser mein open ho
jayega.
Summary
- LinkLabel ek aisa label hai jo hyperlinks ko support karta hai, jisse koi web link ya internal
functionality perform ho sakti hai.
- Ismein properties jaise LinkColor, VisitedLinkColor, aur ActiveLinkColor hoti hain jisse
link ka appearance control hota hai.
- LinkClicked event ka use kar ke hum kisi link pe click hone par kuch actions perform kar
sakte hain, jaise kisi website ko browser mein open karna.
LinkLabel ka use application mein navigation aur hyperlinks provide karne ke liye hota hai,
jo user ke experience ko improve karta hai aur relevant links ko directly access karne ki
suvidha deta hai.
Buttons:
Button control Windows Forms mein ek sabse commonly used control hai jo user
interactions ke liye use hota hai. Yeh ek clickable element hai jisse user koi specific action
trigger kar sakta hai. Buttons ka use forms submit karne, data process karne, aur
application mein different actions perform karne ke liye hota hai.
- Namespace: `System.Windows.Forms`
- Purpose: Button ek clickable control hai jo kisi specific event ko trigger karta hai, jaise ki
form submit karna ya kisi process ko start karna.
- Common Use Cases: User se input lene ke baad submit button, next/previous navigation,
save button, ya actions perform karne ke liye button.
Common Properties of Button
1. Text:
- Example:
```csharp
myButton.Text = "Submit";
```
2. Font:
- Example:
```csharp
```
3. BackColor:
- Example:
```csharp
myButton.BackColor = Color.LightBlue;
```
4. ForeColor:
```csharp
myButton.ForeColor = Color.White;
```
5. Enabled:
- Button ko enable ya disable karta hai. Agar `false` ho toh button click nahi hoga.
- Example:
```csharp
```
6. FlatStyle:
- Example:
```csharp
myButton.FlatStyle = FlatStyle.Flat;
```
7. Image:
- Example:
```csharp
myButton.Image = Image.FromFile("path/to/image.png");
```
Common Methods of Button
1. PerformClick():
- Example:
```csharp
```
1. Click:
- Jab user button par click karega, toh yeh event trigger hota hai.
- Example:
```csharp
MessageBox.Show("Button Clicked!");
```
- MouseEnter tab trigger hota hai jab mouse pointer button par aaye.
- MouseLeave tab trigger hota hai jab mouse pointer button se bahar jaye.
- Example:
```csharp
```
Yeh ek example hai jisme hum ek Button ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
// Label create karte hain taaki button click hone par message dikhaye
myLabel.AutoSize = true;
this.Controls.Add(myButton);
this.Controls.Add(myLabel);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
}
```
Is example mein:
- Button create kiya gaya hai jisme "Click Me!" text hai.
- Jab user button ko click karta hai, toh label ka text change ho jata hai ("Button clicked!").
Summary
- Button control ek clickable element hai jiska use user interactions handle karne ke liye
hota hai.
- Ismein properties jaise Text, Font, BackColor, aur ForeColor hain jo button ka appearance
customize karne mein help karti hain.
- Click event ka use button click hone par kuch actions perform karne ke liye hota hai.
Button Windows Forms mein sabse commonly used controls mein se ek hai, kyunki iska
use kisi bhi form mein user se interaction lene, actions perform karne, ya form submit
karne ke liye hota hai.
Checkboxes:
CheckBox control Windows Forms mein ek input control hai jiska use true/false ya yes/no
type options ko represent karne ke liye hota hai. Yeh ek chhoti si box jaisi hoti hai, jisko
user select (check) ya deselect (uncheck) kar sakta hai. CheckBoxes ko multiple choices
provide karne ke liye use kiya ja sakta hai.
- Purpose: Yeh user ko ek ya zyada options choose karne ke liye allow karta hai. User ek ya
multiple CheckBox select ya deselect kar sakta hai.
- Common Use Cases: User preferences collect karna, settings on/off karna, ya kisi form
mein multiple responses lene ke liye.
1. Text:
- Example:
```csharp
```
2. Checked:
- Yeh property batati hai ki CheckBox checked hai ya nahi (true ya false).
- Example:
```csharp
```
3. CheckState:
```csharp
```
4. AutoCheck:
- Agar `true` ho toh user CheckBox par click karke usko check/uncheck kar sakta hai.
Agar `false` set ho toh aapko manually state manage karni padegi.
- Example:
```csharp
myCheckBox.AutoCheck = true;
```
5. ThreeState:
- Agar `true` ho, toh CheckBox ke paas three states ho sakti hain: `Checked`,
`Unchecked`, aur `Indeterminate`.
- Example:
```csharp
myCheckBox.ThreeState = true;
```
CheckBoxes mein methods limited hain kyunki unka use sirf user interactions ke liye hota
hai. Par kuch useful methods hain:
1. PerformClick():
- Programmatically CheckBox click event trigger karta hai.
- Example:
```csharp
```
1. CheckedChanged:
- Jab CheckBox ki checked state change ho jaye, toh yeh event trigger hota hai.
- Example:
```csharp
if (myCheckBox.Checked)
else
```
2. CheckStateChanged:
- Jab CheckBox ki state change ho, toh yeh event trigger hota hai (three-state mode mein
bhi useful hota hai).
- Example:
```csharp
myCheckBox.CheckStateChanged += new
EventHandler(MyCheckBox_CheckStateChanged);
```
Yeh ek example hai jisme hum CheckBox ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
{
private CheckBox myCheckBox;
public MyForm()
myCheckBox.CheckedChanged += new
EventHandler(MyCheckBox_CheckedChanged);
myLabel.AutoSize = true;
this.Controls.Add(myCheckBox);
this.Controls.Add(myLabel);
if (myCheckBox.Checked)
{
else
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- Jab user CheckBox ko check ya uncheck karta hai, toh Label mein status change ho jata
hai ("Status: Accepted" ya "Status: Not Accepted").
Summary
- CheckBox ek input control hai jo user ko select (check) ya deselect (uncheck) karne ki
suvidha deta hai.
- Ismein properties jaise Text, Checked, ThreeState hain jo CheckBox ka appearance aur
behavior control karne mein help karti hain.
- CheckedChanged event ka use CheckBox ki state change hone par kuch action perform
karne ke liye hota hai.
CheckBox ka use forms mein multiple options collect karne, settings toggle karne, ya kisi
specific preference ko indicate karne ke liye hota hai. Yeh simple aur user-friendly control
hai jo user ke interaction ko easy banata hai.
Radio Buttons:
RadioButton control Windows Forms mein ek input control hai jiska use mutually exclusive
options (matlab ek time par sirf ek option select karna) represent karne ke liye hota hai.
Yeh aise cases mein useful hai jahan user ko ek option select karna ho multiple choices
mein se, jaise ki gender selection, yes/no, ya payment method select karna.
- Namespace: `System.Windows.Forms`
- Purpose: User ko ek group mein se sirf ek option select karne ke liye use hota hai.
- Common Use Cases: User se options choose karwane ke liye jahan sirf ek hi option valid
ho, jaise "Gender" selection (`Male`, `Female`), payment method (`Credit Card`, `Debit
Card`), etc.
1. Text:
- RadioButton ke saath display hone wala text set karta hai.
- Example:
```csharp
myRadioButton.Text = "Male";
```
2. Checked:
- Yeh property batati hai ki RadioButton checked hai ya nahi (`true` ya `false`).
- Example:
```csharp
```
3. AutoCheck:
- Agar `true` ho toh user RadioButton par click karke usko check/uncheck kar sakta hai.
Agar `false` ho toh manually state manage karni padegi.
- Example:
```csharp
myRadioButton.AutoCheck = true;
```
4. Appearance:
- Example:
```csharp
myRadioButton.Appearance = Appearance.Button; // RadioButton ko ek button ki tarah
dikhaega
```
5. CheckedChanged:
- Jab RadioButton ki checked state change ho, toh yeh event trigger hota hai.
- Example:
```csharp
myRadioButton.CheckedChanged += new
EventHandler(MyRadioButton_CheckedChanged);
if (myRadioButton.Checked)
else
```
Grouping RadioButtons
RadioButtons ko group mein organize kiya jata hai taaki ek time par sirf ek hi option select
ho. Iska best tarika hai ki aap RadioButtons ko kisi GroupBox ya Panel ke andar rakhein.
Agar aap saare RadioButtons ek hi GroupBox mein daalenge, toh ek hi time par sirf ek
RadioButton select ho paayega.
Example:
```csharp
maleRadioButton.Text = "Male";
femaleRadioButton.Text = "Female";
myGroupBox.Controls.Add(maleRadioButton);
myGroupBox.Controls.Add(femaleRadioButton);
this.Controls.Add(myGroupBox);
```
- Jab RadioButton ki state change ho, tab yeh event trigger hota hai.
- Iska use aap ye jaanne ke liye kar sakte hain ki kaunsa option select ho gaya.
- Example:
```csharp
myRadioButton.CheckedChanged += new
EventHandler(MyRadioButton_CheckedChanged);
```
2. Click:
- Jab user RadioButton par click karta hai toh yeh event trigger hota hai.
- Example:
```csharp
```
Yahan ek example hai jisme hum RadioButton ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public class MyForm : Form
public MyForm()
maleRadioButton.Text = "Male";
maleRadioButton.CheckedChanged += new
EventHandler(RadioButton_CheckedChanged);
femaleRadioButton.Text = "Female";
genderGroupBox.Controls.Add(maleRadioButton);
genderGroupBox.Controls.Add(femaleRadioButton);
myLabel.AutoSize = true;
this.Controls.Add(genderGroupBox);
this.Controls.Add(myLabel);
if (maleRadioButton.Checked)
else if (femaleRadioButton.Checked)
{
myLabel.Text = "Gender: Female";
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- GroupBox use kiya gaya hai jisme do RadioButtons hain - `Male` aur `Female`.
- Jab user koi RadioButton select karta hai, toh Label mein selected gender dikhaya jata
hai.
Summary
- RadioButton control user ko multiple options mein se ek select karne ki suvidha deta hai.
- Ismein properties jaise Text, Checked, aur Appearance hoti hain jo RadioButton ka
appearance aur behavior control karne mein help karti hain.
- CheckedChanged event ka use RadioButton ki state change hone par kuch action
perform karne ke liye hota hai.
- RadioButtons ko ek group mein daalne ke liye GroupBox ya Panel ka use hota hai, taaki ek
hi time par ek option select ho.
RadioButton ek important control hai jiska use tab hota hai jab multiple options mein se
sirf ek select karna ho, aur yeh Windows Forms applications mein user input ko easy aur
effective banata hai.
Panels:
Panel control Windows Forms mein ek container control hai, jiska use aapko multiple
controls ko logically group karne, organize karne, aur complex UI layouts banane mein
hota hai. Yeh ek rectangular container hai jisme aap kisi bhi tarah ke controls, jaise
buttons, labels, textboxes, aur listboxes ko add kar sakte hain.
- Namespace: `System.Windows.Forms`
- Purpose: Multiple controls ko ek container mein logically group karne aur layout manage
karne ke liye use hota hai. Yeh ek rectangular section create karta hai jisme aur controls
add kiye ja sakte hain.
- Common Use Cases: User interface ka layout manage karna, form mein specific sections
create karna (jaise sidebar, header), ya related controls ko visually group karna.
1. BackColor:
- Example:
```csharp
myPanel.BackColor = Color.LightGray; // Panel ka background color light gray ho jayega
```
2. BorderStyle:
- Panel ke border ka style set karta hai. Options hain `None`, `FixedSingle`, aur
`Fixed3D`.
- Example:
```csharp
```
3. Size:
- Example:
```csharp
myPanel.Size = new Size(200, 150); // Width 200 aur height 150 set karta hai
```
4. Location:
- Example:
```csharp
myPanel.Location = new Point(50, 30); // Panel ki position (x=50, y=30) set karta hai
```
5. AutoScroll:
- Agar controls panel ke andar fit nahi ho rahe hain toh scroll bars enable karne ke liye use
hota hai.
- Example:
```csharp
myPanel.AutoScroll = true; // Panel mein scroll bars enable ho jayenge agar content
panel se bada ho
```
6. Controls:
- Panel mein add kiye gaye child controls ko manage karta hai.
- Example:
```csharp
```
1. Controls.Add():
- Panel mein child controls add karne ke liye use hota hai.
- Example:
```csharp
```
2. Clear():
- Panel ke andar saare child controls ko remove karta hai.
- Example:
```csharp
```
Yahan ek example hai jisme hum Panel ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myPanel.BorderStyle = BorderStyle.FixedSingle;
myLabel.AutoSize = true;
myPanel.Controls.Add(button1);
myPanel.Controls.Add(button2);
myPanel.Controls.Add(myLabel);
this.Controls.Add(myPanel);
}
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- Panel ka use kiya gaya hai `button1`, `button2`, aur `myLabel` ko group karne ke liye.
- Panel ek container ki tarah kaam karta hai jisme aap multiple controls add kar sakte hain
aur unka layout manage kar sakte hain.
1. Layout Management:
- Panel ka use complex layouts banane mein hota hai. Aap form ke different sections
create kar sakte hain, jaise header, footer, sidebar, etc.
2. Scroll Bars:
- Jab panel mein content panel ke size se bada ho, toh AutoScroll property use karke
scroll bars enable kiye ja sakte hain.
3. Grouping Controls:
- Similar controls ko group karke ek logical structure banane ke liye panel ka use kiya jata
hai. Jaise kisi section mein settings ya specific inputs ko group karna.
Summary
- Panel ek container control hai jiska use multiple controls ko ek saath logically group
karne aur UI layout manage karne ke liye hota hai.
- Yeh BackColor, BorderStyle, AutoScroll, aur Controls jaise properties provide karta hai
jisse aap panel ka appearance aur functionality customize kar sakte hain.
- Panel ka use form mein sections create karne, related controls ko visually group karne,
aur scroll functionality add karne ke liye hota hai.
Panel Windows Forms applications mein kaafi important control hai kyunki yeh aapko ek
structured aur maintainable layout banane mein madad karta hai, jisse user experience
aur bhi improve hota hai.
Group Boxes:
GroupBox control Windows Forms mein ek container control hai, jiska use related controls
ko logically group karne ke liye hota hai. Yeh ek rectangular border aur title ke saath aata
hai, jo visually ek section define karta hai. GroupBox ka use aapko tab ka rna chahiye jab
aapko kisi specific context mein related controls ko group karna ho, jaise settings, radio
buttons, ya kisi form ke sections.
- Namespace: `System.Windows.Forms`
- Purpose: Yeh ek container hai jisme related controls ko logically group kiya jata hai, aur
iska ek title hota hai jo us group ka purpose define karta hai.
- Common Use Cases: Related options, radio buttons, settings ko logically group karne ke
liye, jisse form ka structure clear ho aur user ke liye understanding easy ho.
1. Text:
- Yeh property GroupBox ka title set karti hai, jo group ka naam ya context define karta
hai.
- Example:
```csharp
```
2. Font:
- Example:
```csharp
myGroupBox.Font = new Font("Arial", 10, FontStyle.Bold); // Title ka font Arial aur bold
ho jayega
```
3. Size:
- Example:
```csharp
myGroupBox.Size = new Size(200, 150); // GroupBox ki width 200 aur height 150 set
karega
```
4. Location:
- Yeh property GroupBox ki position set karti hai, jo uska parent control ke hisaab se hota
hai.
- Example:
```csharp
```
5. Controls:
- Yeh property GroupBox mein child controls add karne ya manage karne ke liye use hoti
hai.
- Example:
```csharp
```
1. Controls.Add():
- Yeh method child controls ko GroupBox mein add karne ke liye use hota hai.
- Example:
```csharp
```
- Example:
```csharp
```
Yahan ek example hai jisme hum GroupBox ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
{
radioButton1.Text = "Male";
radioButton2.Text = "Female";
myGroupBox.Controls.Add(radioButton1);
myGroupBox.Controls.Add(radioButton2);
this.Controls.Add(myGroupBox);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- GroupBox ka use `Male` aur `Female` radio buttons ko group karne ke liye kiya gaya hai.
- GroupBox ka title "Select Gender" hai, jisse user ko samajhne mein asaani hoti hai ki yeh
options gender select karne ke liye hain.
- Jab aapko form mein related options ko logically group karna ho, toh GroupBox useful
hota hai. Jaise radio buttons, checkboxes, ya settings ke controls.
- GroupBox ka title group ke purpose ko clear karta hai, jisse user ko samajhne mein
asaani hoti hai ki ek specific section kis cheez ke liye hai.
3. Organizing Forms:
- Jab aapke form mein multiple sections hain, jaise personal information, address,
payment details, toh aap alag-alag GroupBox use karke in sections ko logically divide kar
sakte hain, jisse form ka structure better aur easy to navigate ho jata hai.
Summary
- GroupBox ek container control hai jiska use related controls ko logically group karne ke
liye hota hai.
- Ismein properties jaise Text, Font, Size, aur Location hoti hain jisse aap GroupBox ka
appearance aur behavior customize kar sakte hain.
- Yeh related options, jaise radio buttons ya checkboxes, ko ek clear context ke saath
group karne mein madad karta hai.
List Boxes:
ListBox control Windows Forms mein ek aisa control hai jiska use ek list of items ko display
karne ke liye hota hai. ListBox aapko ek ya zyada items select karne ki suvidha deta hai, aur
iska use forms mein options, values, ya lists dikhane ke liye hota hai jahan user kuch select
kar sakta hai.
- Namespace: `System.Windows.Forms`
- Purpose: Ek list of items ko display karna, jismein se user ek ya zyada items select kar
sakta hai.
- Common Use Cases: Dropdown ya combo box ki tarah options dikhane, items ko select
karne ya display karne ke liye, jaise cities list, hobbies list, product selection, etc.
Common Properties of ListBox
1. Items:
- Yeh property ListBox mein items add karne ya manage karne ke liye use hoti hai.
- Example:
```csharp
```
2. SelectedItem:
- Example:
```csharp
var selectedItem = myListBox.SelectedItem; // Select kiya hua item get karta hai
```
3. SelectedIndex:
- Example:
```csharp
int index = myListBox.SelectedIndex; // Select kiya hua item ka index get karta hai
```
4. SelectionMode:
- Yeh property define karti hai ki user ek ya multiple items select kar sakta hai. Options
hain:
- Example:
```csharp
```
5. Sorted:
- Agar `true` set ho, toh ListBox ke items automatically sorted order mein dikhaye jaate
hain.
- Example:
```csharp
myListBox.Sorted = true;
```
1. Items.Add():
- Example:
```csharp
myListBox.Items.Add("Orange");
```
2. Items.Remove():
- Example:
```csharp
```
3. Items.RemoveAt():
- Example:
```csharp
```
4. Items.Clear():
- Example:
```csharp
```
- Jab user kisi naya item ko select karta hai toh yeh event trigger hota hai.
- Example:
```csharp
myListBox.SelectedIndexChanged += new
EventHandler(MyListBox_SelectedIndexChanged);
if (myListBox.SelectedItem != null)
```
Yahan ek example hai jisme hum ListBox ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myListBox.SelectionMode = SelectionMode.One;
myListBox.Items.Add("Apple");
myListBox.Items.Add("Banana");
myListBox.Items.Add("Cherry");
myListBox.Items.Add("Grapes");
myListBox.SelectedIndexChanged += new
EventHandler(MyListBox_SelectedIndexChanged);
this.Controls.Add(myListBox);
this.Controls.Add(myLabel);
if (myListBox.SelectedItem != null)
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- ListBox banaya gaya hai jisme kuch fruits (e.g. Apple, Banana, Cherry) add kiye gaye hain.
- Jab user koi item select karta hai, toh Label mein selected item dikhaya jata hai.
- Jab aapko ek list of options dikhani ho, jaise available cities, products, ya hobbies, toh
ListBox useful hai.
2. Multi-Selection:
- Jab aapko user se ek se zyada options choose karwane ho, toh aap
SelectionMode.MultiSimple ya MultiExtended set kar sakte hain.
3. Navigating or Filtering:
- ListBox ka use forms mein navigation ya items filter karne ke liye bhi hota hai. Jaise kisi
product list ko show karke user se ek ya zyada products select karwana.
Summary
- ListBox ek control hai jiska use ek list of items ko display karne ke liye hota hai, jisme se
user ek ya zyada items select kar sakta hai.
- Ismein properties jaise Items, SelectedItem, SelectionMode, aur Sorted hain, jo ListBox
ke appearance aur behavior ko control karne mein help karti hain.
- SelectedIndexChanged event ka use tab hota hai jab user koi naya item select karta hai.
ListBox Windows Forms mein ek commonly used control hai jo user interaction ko easy
banata hai aur form mein ek achha layout option provide karta hai.
Checked List Boxes:
CheckedListBox Windows Forms mein ek special type ka list control hai, jiska use ek list of
items ko display karne ke saath-saath unhe check/uncheck karne ke liye hota hai. Yeh
ListBox ka advanced version hai jisme har item ke saath ek checkbox hota hai, jisse user ek
ya zyada items ko easily select kar sakta hai.
- Namespace: `System.Windows.Forms`
- Purpose: Ek list of items display karta hai jisme user individual items ko check/uncheck
kar sakta hai.
- Common Use Cases: User preferences collect karna, multi-selection choices dena, jaise
features ko enable/disable karna, settings ko on/off karna, ya hobbies select karne ka
option.
1. Items:
- CheckedListBox mein items add ya manage karne ke liye use hoti hai.
- Example:
```csharp
myCheckedListBox.Items.Add("Option 1");
```
2. CheckedItems:
- Yeh property CheckedListBox ke andar currently checked items ko return karti hai.
- Example:
```csharp
```
3. CheckedIndices:
- Example:
```csharp
```
4. CheckOnClick:
- Agar `true` set ho, toh user ek baar item par click karke usko check/uncheck kar sakta
hai.
- Example:
```csharp
```
Common Methods of CheckedListBox
1. SetItemChecked():
- Yeh method specific item ko checked ya unchecked set karta hai, index ke hisaab se.
- Example:
```csharp
```
2. SetItemCheckState():
- Yeh method specific item ki state set karta hai (`Checked`, `Unchecked`, ya
`Indeterminate`).
- Example:
```csharp
```
1. ItemCheck:
- Jab user kisi item ko check ya uncheck karta hai, toh yeh event trigger hota hai.
- Iska use hum real-time changes ko handle karne ke liye kar sakte hain.
- Example:
```csharp
myCheckedListBox.ItemCheck += new
ItemCheckEventHandler(MyCheckedListBox_ItemCheck);
if (e.NewValue == CheckState.Checked)
else
```
Yahan ek example hai jisme hum CheckedListBox ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public class MyForm : Form
public MyForm()
myCheckedListBox.CheckOnClick = true;
myCheckedListBox.Items.Add("Apple");
myCheckedListBox.Items.Add("Banana");
myCheckedListBox.Items.Add("Cherry");
myCheckedListBox.Items.Add("Grapes");
myLabel.AutoSize = true;
this.Controls.Add(myCheckedListBox);
this.Controls.Add(myButton);
this.Controls.Add(myLabel);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- CheckedListBox banaya gaya hai jisme kuch fruits add kiye gaye hain.
- User selected items dekh sakta hai jab Button par click karega. Label mein saare selected
items show ho jayenge.
1. Preferences Selection:
- Jab aapko user se multiple preferences puchni ho, jaise hobbies, preferred features, ya
enable/disable settings, toh CheckedListBox useful hai.
2. Multi-Choice Options:
- Jab form mein multiple choice select karwani ho, jaise surveys ya quiz options, toh
CheckedListBox use kar sakte hain.
3. To-Do Lists:
- CheckedListBox ko to-do list banane mein use kar sakte hain, jisme items ko
check/uncheck karke mark kiya jaye ki kaunsa task complete ho gaya hai.
Summary
- CheckedListBox ek control hai jiska use ek list of items ko display karne aur unhe
check/uncheck karne ke liye hota hai.
- Ismein properties jaise Items, CheckedItems, CheckOnClick, aur methods jaise
SetItemChecked() hain jo aapko items ko manage karne aur control karne mein help karte
hain.
- ItemCheck event ka use tab hota hai jab user kisi item ko check/uncheck karta hai.
CheckedListBox Windows Forms mein ek useful control hai jab aapko multi-selection
choices dikhani ho, jisse user apni preferences check/uncheck karke select kar sake. Yeh
user ko ek simple aur interactive way deta hai multiple options select karne ka.
Combo Boxes:
ComboBox control Windows Forms mein ek input control hai jiska use ek list of options
dikhane ke liye hota hai, jahan user drop-down list se kisi ek option ko select kar sakta hai
ya phir manually text enter kar sakta hai. ComboBox ek combination hota hai TextBox aur
ListBox ka, jismein drop-down list bhi hoti hai aur user input bhi type kar sakta hai.
- Namespace: `System.Windows.Forms`
- Purpose: Ek list of items dikhana, jisme user drop-down list se select kar sakta hai ya
manually value enter kar sakta hai.
- Common Use Cases: Form fields mein fixed options dene ke liye, jaise country select
karna, gender, ya categories select karna.
1. Items:
- ComboBox mein options add ya manage karne ke liye use hoti hai.
- Example:
```csharp
myComboBox.Items.Add("Option 1");
```
2. Text:
- Yeh property currently selected value ya typed value ko represent karti hai.
- Example:
```csharp
```
3. SelectedItem:
- Example:
```csharp
var selectedItem = myComboBox.SelectedItem; // Select kiya hua item get karta hai
```
4. SelectedIndex:
- Yeh property selected item ka index return karti hai (`-1` ka matlab hai ki koi item
selected nahi hai).
- Example:
```csharp
int index = myComboBox.SelectedIndex; // Select kiya hua item ka index get karta hai
```
5. DropDownStyle:
- Yeh property ComboBox ke appearance aur behavior ko define karti hai. Options hain:
- `ComboBoxStyle.DropDown` - User list se select kar sakta hai ya kuch type kar sakta
hai.
- `ComboBoxStyle.DropDownList` - User sirf list se hi select kar sakta hai (kuch type
nahi kar sakta).
- Example:
```csharp
```
6. MaxDropDownItems:
- Yeh property specify karti hai ki drop-down list mein maximum kitne items dikhaye
jayenge (scrolling ke liye).
- Example:
```csharp
```
- Example:
```csharp
myComboBox.Items.Add("Orange");
```
2. Items.Remove():
- Example:
```csharp
myComboBox.Items.Remove("Option 2");
```
3. Items.Clear():
- Example:
```csharp
myComboBox.Items.Clear();
```
1. SelectedIndexChanged:
- Jab user kisi naya item ko select karta hai toh yeh event trigger hota hai.
- Example:
```csharp
myComboBox.SelectedIndexChanged += new
EventHandler(MyComboBox_SelectedIndexChanged);
if (myComboBox.SelectedItem != null)
```
2. TextChanged:
- Jab ComboBox mein text change hota hai (chahe user type kare ya item select kare), tab
yeh event trigger hota hai.
- Example:
```csharp
```
Yahan ek example hai jisme hum ComboBox ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
myComboBox.Items.Add("Apple");
myComboBox.Items.Add("Banana");
myComboBox.Items.Add("Cherry");
myComboBox.Items.Add("Grapes");
myComboBox.SelectedIndexChanged += new
EventHandler(MyComboBox_SelectedIndexChanged);
// Label create karte hain jo selected item show kare
myLabel.AutoSize = true;
this.Controls.Add(myComboBox);
this.Controls.Add(myLabel);
if (myComboBox.SelectedItem != null)
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
}
}
```
Is example mein:
- ComboBox banaya gaya hai jisme kuch fruits (e.g., Apple, Banana, Cherry) add kiye gaye
hain.
- Jab user koi item select karta hai, toh Label mein selected item dikhaya jata hai.
1. Drop-down Menus:
- Jab aapko limited number of fixed options dene ho jahan user ek select kar sake, jaise
countries, cities, departments, toh ComboBox useful hai.
2. Auto-Complete Input:
- Jab aapko user se koi value enter karwani ho jisme fixed options ho aur aap user ko
typing mein madad karna chahte ho.
- User preferences ya settings jahan kuch specific options ho, jaise theme (`Light`,
`Dark`) ya language (`English`, `Hindi`).
Summary
- ComboBox control ek list of items show karta hai, jisme user kisi ek option ko select kar
sakta hai ya manually kuch type kar sakta hai.
- ComboBox mein properties jaise Items, Text, DropDownStyle, aur methods jaise Add(),
Remove() hain jo ComboBox ke behavior ko control karne mein help karti hain.
- SelectedIndexChanged event ka use tab hota hai jab user koi naya item select karta hai.
ComboBox Windows Forms mein ek kaafi useful aur commonly used control hai, jo user ko
ek list se selection karne ya input enter karne ka asaan tarika deta hai, aur iska use forms
mein user experience ko improve karne ke liye hota hai.
Picture Boxes:
PictureBox control Windows Forms mein ek control hai jiska use images ko display karne
ke liye hota hai. PictureBox ka use tab hota hai jab aapko kisi application mein image show
karni ho, jaise icons, logos, product images, ya kisi visual representation ko dikhana.
- Namespace: `System.Windows.Forms`
- Purpose: Image ko display karne ke liye, kisi application mein visual representation
dikhane ke liye use hota hai.
- Common Use Cases: Application mein logos, user profile pictures, product images,
photo gallery ya kisi bhi visual content ko dikhane ke liye.
1. Image:
- PictureBox mein display hone wali image ko set ya get karta hai.
- Example:
```csharp
```
2. ImageLocation:
- Yeh property image ki location set karne ke liye use hoti hai. Yeh image ko URL ya local
path se load karne mein help karti hai.
- Example:
```csharp
```
3. SizeMode:
- Yeh property define karti hai ki PictureBox mein image kaise fit hogi. Options hain:
- `Zoom` - Image ko PictureBox ke andar zoom karta hai bina aspect ratio ko lose kiye.
- Example:
```csharp
```
4. BorderStyle:
- PictureBox ke border ka style set karta hai. Options hain `None`, `FixedSingle`, aur
`Fixed3D`.
- Example:
```csharp
```
1. Load():
- Example:
```csharp
```
2. LoadAsync():
- Image ko asynchronously load karta hai, yeh tab useful hai jab aapko image ko URL se
load karna ho aur form ko freeze hone se bachana ho.
- Example:
```csharp
```
Yahan ek example hai jisme hum PictureBox ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myPictureBox.BorderStyle = BorderStyle.FixedSingle;
myPictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
this.Controls.Add(loadImageButton);
myPictureBox.Image = Image.FromFile("path/to/your/image.jpg");
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- PictureBox banaya gaya hai jisme ek image show hoti hai jab Button par click kiya jaye.
- User button par click karke local file se image load kar sakta hai.
1. Logo or Branding:
- Application mein logo ya branding image dikhane ke liye PictureBox use hota hai.
2. Photo Gallery:
- PictureBox ka use photo gallery banane mein bhi ho sakta hai jahan user ek image
dekhe aur navigation buttons se agli ya pichli image dekhe.
3. Profile Pictures:
- User forms mein profile picture dikhane ke liye ya profile picture upload karne ke baad
preview dikhane ke liye.
- E-commerce applications mein kisi product ko visualize karwane ke liye use hota hai.
Summary
- PictureBox ek control hai jiska use images ko display karne ke liye hota hai.
- Ismein properties jaise Image, ImageLocation, SizeMode, aur BorderStyle hain jisse
PictureBox ka appearance aur behavior customize hota hai.
PictureBox ka use applications mein visual elements dikhane ke liye hota hai, jisse user
experience aur bhi improve ho jata hai, aur user ko kisi bhi visual content ko easily present
kiya ja sakta hai.
Scroll Bars:
ScrollBar control Windows Forms mein ek control hai jiska use content ko horizontally ya
vertically scroll karne ke liye hota hai. Yeh tab useful hai jab content bada ho aur ek saath
screen par fit na ho sake. Windows Forms mein do tarah ke scroll bars hain:
ScrollBars Windows Forms ke Panel, ListBox, ya kisi bhi control mein AutoScroll feature ke
saath bhi kaam kar sakte hain, jahan scroll bars automatically tab dikhte hain jab content
control ke size se bada ho.
- Namespace: `System.Windows.Forms`
- Purpose: Content ko scroll karne ke liye horizontal ya vertical scroll bars provide karta
hai.
- Common Use Cases: Jab content ek window ya form mein fit na ho paaye, tab scroll bars
use karte hain. Jaise forms mein extra information ko display karne ke liye ya kisi image ko
scroll karne ke liye.
1. HScrollBar: Yeh ek horizontal scroll bar hai jo content ko horizontally scroll karne ke liye
use hota hai.
2. VScrollBar: Yeh ek vertical scroll bar hai jo content ko vertically scroll karne ke liye use
hota hai.
- Scroll bar ka minimum value set karta hai, jisse scroll bar shuru hota hai.
- Example:
```csharp
```
2. Maximum:
- Scroll bar ka maximum value set karta hai, jisse scroll bar khatam hota hai.
- Example:
```csharp
```
3. Value:
- Example:
```csharp
```
4. LargeChange:
- Yeh property specify karti hai ki scroll bar ka thumb (slider) kitna move karega jab user
page up/page down ya scrollbar track pe click karega.
- Example:
```csharp
myScrollBar.LargeChange = 10; // Thumb ek baar mein 10 units move karega
```
5. SmallChange:
- Yeh property specify karti hai ki scroll bar ka thumb kitna move karega jab user arrow
button press karega.
- Example:
```csharp
```
Scroll bars ke methods limited hain kyunki scroll bars mainly user interactions handle
karte hain. Lekin kuch common methods hain:
1. PerformScroll():
1. Scroll:
- Jab user scroll bar ko move karta hai toh yeh event trigger hota hai.
- Example:
```csharp
```
2. ValueChanged:
- Jab scroll bar ki value change ho jaye toh yeh event trigger hota hai.
- Example:
```csharp
```
Yahan ek example hai jisme hum HScrollBar aur VScrollBar ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
hScrollBar.Width = 200;
hScrollBar.Minimum = 0;
hScrollBar.Maximum = 100;
vScrollBar.Height = 150;
vScrollBar.Minimum = 0;
vScrollBar.Maximum = 100;
myLabel.AutoSize = true;
this.Controls.Add(hScrollBar);
this.Controls.Add(vScrollBar);
this.Controls.Add(myLabel);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
}
```
Is example mein:
- HScrollBar aur VScrollBar banaye gaye hain jinki value jab bhi change hoti hai, toh ek
Label mein dikhaya jata hai.
- Yeh scroll bars user ko values scroll karke adjust karne ki suvidha dete hain.
- Jab content bada ho aur ek screen mein fit na ho, toh ScrollBar ya AutoScroll feature ka
use hota hai, jaise long forms, images, ya text content.
- Jab controls dynamically add hote hain aur form ke size se badh jaate hain, toh scroll
bars useful hote hain taaki user content ko easily navigate kar sake.
- Jab large images display karni ho aur user ko zoom-in ya panning ka option dena ho.
Summary
- ScrollBar ek control hai jiska use content ko vertically ya horizontally scroll karne ke liye
hota hai.
- HScrollBar horizontal scrolling ke liye aur VScrollBar vertical scrolling ke liye use hota hai.
- Minimum, Maximum, Value, aur LargeChange jaise properties use karke aap scroll bar ka
behavior control kar sakte hain.
- Scroll aur ValueChanged events ka use tab hota hai jab user scroll bar ko move karta hai.
ScrollBar Windows Forms applications mein kaafi useful control hai jab content bada ho
aur user ke screen ke size mein fit na ho. Yeh control ek better user experience provide
karta hai, jisse user content ko easily access aur navigate kar sakta hai.
Splitters:
Splitter control Windows Forms mein ek useful control hai jiska use UI ko dynamically
resize karne ke liye hota hai. Splitter ka use tab hota hai jab form mein multiple panes ya
panels ho jahan user in panes ko drag karke resize kar sake. Yeh control mainly UI ko
interactive banane aur user preferences ke hisaab se layout customize karne mein help
karta hai.
- Namespace: `System.Windows.Forms`
- Purpose: Splitter ek movable divider hai jo form ke different panels ya sections ko resize
karne mein use hota hai.
- Common Use Cases: Application mein panels ko resize karne ke liye, jaise file explorer
mein directory pane aur file pane ko resize karna ya kisi dashboard mein left pane
(navigation) aur right pane (content) ko resize karne ke liye.
- Splitter ka use Panel controls ya other container controls ke saath hota hai.
- Yeh ek movable bar provide karta hai jisse user different sections ko drag karke resize kar
sakta hai.
- Yeh horizontal ya vertical dono directions mein kaam kar sakta hai.
Common Properties of Splitter
1. Dock:
- Yeh property specify karti hai ki Splitter ko parent container mein kis direction mein dock
kiya jaye. Options hain `Top`, `Bottom`, `Left`, `Right`.
- Example:
```csharp
```
2. MinExtra:
- Yeh property Splitter ke right ya bottom panel ke minimum size ko specify karti hai, taaki
user isse chhota na kar sake.
- Example:
```csharp
```
3. MinSize:
- Yeh property Splitter ke left ya top panel ke minimum size ko specify karti hai.
- Example:
```csharp
```
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
leftPanel.BackColor = Color.LightBlue;
leftPanel.Dock = DockStyle.Left;
leftPanel.Width = 150;
rightPanel.BackColor = Color.LightGreen;
rightPanel.Dock = DockStyle.Fill;
// Splitter create aur configure karte hain
mySplitter.Dock = DockStyle.Left; // Splitter ko left side mein dock kar rahe hain
(between panels)
mySplitter.MinExtra = 100; // Right panel ka minimum size set kar rahe hain
mySplitter.MinSize = 50; // Left panel ka minimum size set kar rahe hain
this.Controls.Add(rightPanel);
this.Controls.Add(mySplitter);
this.Controls.Add(leftPanel);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- Left Panel ek fixed width panel hai jisme Splitter dock kiya gaya hai.
- User Splitter ko drag karke Left Panel aur Right Panel ka size adjust kar sakta hai.
- Yeh layout applications mein interactive aur user-customizable sections banane mein
help karta hai.
- Jab application mein ek navigation pane aur ek content pane ho, toh Splitter ka use user
ko panels ko resize karne ka option dene ke liye hota hai.
- Jahan ek side directory tree aur doosri side files ho, toh Splitter use karke user in dono
sections ko adjust kar sakta hai.
3. Two-Panel Applications:
- Dual-pane applications jaise email client jahan ek pane mein folders hain aur doosre
mein emails ki list, user un panels ko resize kar sake.
Summary
- Splitter ek control hai jiska use panels ko dynamically resize karne ke liye hota hai.
- Splitter ko Dock property se set kiya jata hai aur MinExtra aur MinSize properties use
karke resizing limits set ki ja sakti hain.
- Yeh Panel ya kisi bhi container control ke saath kaam karta hai aur user ko interactive UI
experience provide karta hai.
Splitter Windows Forms applications mein ek powerful control hai, jo user ko flexibility
deta hai apni screen space ko customize karne ka. Yeh interactive layouts banane mein
madad karta hai, jisse user experience improve hota hai aur application user-friendly banti
hai.
Track Bars:
TrackBar control Windows Forms mein ek useful input control hai jiska use numerical
values ko graphically select karne ke liye hota hai. TrackBar ek sliding bar hota hai jisme ek
movable thumb (slider) hota hai jisko user drag karke ek specific value select kar sakta hai.
Yeh volume controls, brightness settings, ya kisi bhi range-based selection ke liye use hota
hai.
- Namespace: `System.Windows.Forms`
- Purpose: TrackBar ka use user ko ek value select karne ke liye hota hai ek defined range
mein se, jahan values ko user ek sliding thumb se adjust kar sakta hai.
- Common Use Cases: Volume control, brightness adjustment, progress setting, animation
speed selection, ya kisi bhi setting jisme range-based value deni ho.
1. Minimum:
- TrackBar ka minimum value set karta hai, jahan se slider shuru hota hai.
- Example:
```csharp
```
2. Maximum:
- TrackBar ka maximum value set karta hai, jahan tak slider move kar sakta hai.
- Example:
```csharp
```
3. Value:
- TrackBar ki current value ko represent karta hai, jo slider ki current position hai.
- Example:
```csharp
```
4. TickFrequency:
- Yeh property specify karti hai ki ticks (lines) har kitne intervals par honge.
- Example:
```csharp
```
5. SmallChange:
- Yeh property specify karti hai ki value slider ke ek chhote step ke liye kitna change hogi
(e.g. arrow keys).
- Example:
```csharp
6. LargeChange:
- Yeh property specify karti hai ki value slider ke bade step ke liye kitna change hogi (e.g.
page up/page down).
- Example:
```csharp
```
7. Orientation:
- Example:
```csharp
```
1. PerformStep():
- TrackBar ki value ko programmatically ek step aage ya peeche le jaane ke liye use hota
hai.
1. Scroll:
- Jab user TrackBar ko move karta hai, toh yeh event trigger hota hai. Yeh useful hota hai
tab jab aapko real-time update dene ho, jaise volume level adjust karte waqt.
- Example:
```csharp
```
2. ValueChanged:
- Jab TrackBar ki value change hoti hai (chahe user kare ya programmatically), tab yeh
event trigger hota hai.
- Example:
```csharp
```
Yahan ek example hai jisme hum TrackBar ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myTrackBar.Minimum = 0;
myTrackBar.Maximum = 100;
myTrackBar.Value = 50;
myTrackBar.TickFrequency = 10;
myTrackBar.Orientation = Orientation.Horizontal;
myLabel.AutoSize = true;
// Form mein TrackBar aur Label add karte hain
this.Controls.Add(myTrackBar);
this.Controls.Add(myLabel);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- TrackBar banaya gaya hai jo 0 se 100 tak ki values ko control karta hai, aur initial value 50
hai.
- Label mein current value display hoti hai jab user slider ko move karta hai.
- Volume adjust karne ke liye, jahan slider ko drag karke volume ko low ya high set kar
sakte hain.
2. Brightness Control:
- Screen brightness ya kisi image brightness ko adjust karne ke liye TrackBar useful hota
hai.
- Animation speed set karne ya kisi progress ki value ko manually adjust karne ke liye.
4. Zoom Level:
- Image ya text ko zoom in/zoom out karne ke liye TrackBar ka use kiya ja sakta hai.
Summary
- TrackBar ek input control hai jiska use user ko ek specific value select karne ke liye hota
hai ek defined range mein se.
- Yeh numerical value ko graphical slider se represent karta hai, jisse user ko ek value
adjust karne mein madad milti hai.
TrackBar ka use applications mein settings ya preferences ko adjust karne ke liye hota hai,
aur yeh ek simple aur intuitive way hai kisi range-based value ko select karne ka.
Pickers:
Pickers Windows Forms mein aise controls hain jinka use user se specific type ki input
value ko select karwane ke liye hota hai, jaise date, time, ya color. Windows Forms mein
commonly used pickers hain:
2. ColorDialog - User ko ek color choose karne ke liye dialog box provide karne ke liye.
3. FontDialog - User ko ek font select karne ke liye dialog box provide karne ke liye.
1. DateTimePicker Control
DateTimePicker control Windows Forms mein ek aisa control hai jiska use date aur time
input ke liye hota hai. Yeh ek drop-down calendar provide karta hai jisse user easily koi
date ya time select kar sakta hai.
1. Value:
- Example:
```csharp
```
2. Format:
- Yeh property date aur time ka format set karti hai (`Long`, `Short`, `Time`, ya
`Custom`).
- Example:
```csharp
```
- Minimum aur maximum date set karta hai jo user select kar sakta hai.
- Example:
```csharp
```
1. ValueChanged:
- Jab user naya date ya time select karta hai, toh yeh event trigger hota hai.
- Example:
```csharp
myDateTimePicker.ValueChanged += new
EventHandler(MyDateTimePicker_ValueChanged);
{
MessageBox.Show("Selected Date: " + myDateTimePicker.Value.ToShortDateString());
```
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myDateTimePicker.Format = DateTimePickerFormat.Short;
myDateTimePicker.ValueChanged += new
EventHandler(MyDateTimePicker_ValueChanged);
myLabel.AutoSize = true;
this.Controls.Add(myDateTimePicker);
this.Controls.Add(myLabel);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- DateTimePicker banaya gaya hai jisme user ek date select kar sakta hai, aur selected date
Label mein show hoti hai.
2. ColorDialog Control
ColorDialog ek dialog box hai jiska use user se ek color select karwane ke liye hota hai. Yeh
control tab useful hota hai jab aapko kisi control ya background ka color user se set
karwana ho.
1. ShowDialog():
- ColorDialog ko display karta hai aur user se color select karwane ke liye use hota hai.
- Example:
```csharp
if (colorDialog.ShowDialog() == DialogResult.OK)
```
```csharp
if (colorDialog.ShowDialog() == DialogResult.OK)
```
3. FontDialog Control
FontDialog ek dialog box hai jiska use user se ek font select karwane ke liye hota hai. Yeh
control tab useful hota hai jab aapko kisi text ka font, size, ya style change karwana ho.
1. ShowDialog():
- FontDialog ko display karta hai aur user se font select karwane ke liye use hota hai.
- Example:
```csharp
if (fontDialog.ShowDialog() == DialogResult.OK)
}
```
```csharp
if (fontDialog.ShowDialog() == DialogResult.OK)
myLabel.Font = fontDialog.Font; // Label ka font user ke selected font se set hota hai
```
Summary
1. DateTimePicker:
2. ColorDialog:
- User ko ek color select karne ke liye dialog box provide karta hai.
3. FontDialog:
- User ko ek font select karne ke liye dialog box provide karta hai.
- Useful for text formatting jahan user apne according font set kar sake.
Pickers Windows Forms applications mein user interaction ko easy aur user-friendly
banate hain. Yeh user ko specific type ki values (date, color, font) select karne ka
convenient tarika dete hain, jisse application user experience improve hota hai.
Notify Icons:
NotifyIcon control Windows Forms mein ek useful control hai jiska use system tray mein
application icon dikhane ke liye hota hai. NotifyIcon application ko system tray mein
minimize ya background mein run hone ke baad bhi dikhane mein help karta hai, aur user
ko important notifications ya quick access options provide karta hai.
- Namespace: `System.Windows.Forms`
- Purpose: System tray mein icon display karne aur application ko minimize hone ke baad
bhi easily accessible banane ke liye.
- Common Use Cases: Background mein run hone wali applications, like messaging apps,
antiviruses, or system monitoring tools. User ko quick information ya interaction provide
karne ke liye notifications dikhana.
1. Icon:
- NotifyIcon ka icon set karta hai jo system tray mein dikhai deta hai.
- Example:
```csharp
myNotifyIcon.Icon = new Icon("path/to/your/icon.ico");
```
2. Text:
- System tray mein mouse hover hone par dikhne wala tooltip text set karta hai.
- Example:
```csharp
```
3. Visible:
- Example:
```csharp
```
4. ContextMenuStrip:
- NotifyIcon ke saath ek context menu attach karta hai, jisse user ko right-click options
milte hain.
- Example:
```csharp
```
- Example:
```csharp
```
Yahan ek example hai jisme hum NotifyIcon ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myNotifyIcon.ContextMenuStrip = contextMenu;
myNotifyIcon.Visible = true;
if (this.WindowState == FormWindowState.Minimized)
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- NotifyIcon system tray mein dikhaya gaya hai jo form ke minimize hone par ek balloon
notification show karta hai.
- ContextMenuStrip add kiya gaya hai jisme options hain "Open" aur "Exit", jo right-click
karne par dikhai dete hain.
- User Open click karke application ko wapas la sakta hai ya Exit click karke application
close kar sakta hai.
1. Background Applications:
- Jab application ko background mein run karna ho (e.g., messengers, system utilities),
toh NotifyIcon useful hota hai, jisse user ko tray mein icon ke through application access
milta hai.
- NotifyIcon ke saath ContextMenuStrip attach karke quick actions (e.g., open, settings,
exit) provide kiye ja sakte hain.
3. Notifications:
- User ko real-time updates ya alerts dene ke liye (e.g., new messages, system alerts)
balloon tips show kiye ja sakte hain.
Summary
- NotifyIcon Windows Forms application ka ek control hai jiska use system tray mein
application icon dikhane ke liye hota hai.
- Yeh background applications ko manage karne, user ko tray mein notification show
karne, aur context menu ke through quick actions dene mein useful hota hai.
- Common properties hain Icon, Text, Visible, aur ContextMenuStrip, jisse NotifyIcon ka
behavior customize hota hai.
- ShowBalloonTip() method ka use user ko notifications dene ke liye hota hai.
NotifyIcon Windows Forms mein kaafi useful control hai jab aapko application ko minimize
hone ke baad bhi easily accessible aur user-friendly banana ho. Yeh control background
processes manage karne, tray notifications dikhane, aur user interactions improve karne
mein madad karta hai.
Tool Tips:
ToolTip control Windows Forms mein ek helpful control hai jiska use user ko additional
information ya hints provide karne ke liye hota hai jab woh kisi control ke upar mouse hover
karta hai. ToolTip ka use tab hota hai jab aapko user ko kisi control ya fea ture ke baare
mein guide karna ho bina interface clutter kiye.
- Namespace: `System.Windows.Forms`
- Purpose: ToolTip ka use additional information ya hint dene ke liye hota hai jab user kisi
control (e.g., button, textbox, label) ke upar mouse hover karta hai.
- Common Use Cases: Button ke function ko explain karna, input fields mein guidance
dena, ya kisi control ki utility batana.
1. AutomaticDelay:
- Yeh property delay timings ko set karne ke liye use hoti hai. Yeh initial delay, reshow
delay, aur auto-popup delay ko define karta hai.
- Example:
```csharp
```
2. AutoPopDelay:
- Yeh specify karta hai ki ToolTip kitne der tak visible rahega.
- Example:
```csharp
```
3. InitialDelay:
- Yeh specify karta hai ki ToolTip kitne time ke baad visible ho.
- Example:
```csharp
```
4. ReshowDelay:
- Yeh specify karta hai ki ek ToolTip ke baad doosra ToolTip kitne delay ke baad dikhaya
jaaye.
- Example:
```csharp
5. IsBalloon:
- Yeh property set karti hai ki ToolTip balloon style mein dikhaya jaye.
- Example:
```csharp
```
1. SetToolTip(Control, String):
- Yeh method specific control par ToolTip text set karne ke liye use hota hai.
- Example:
```csharp
```
Yahan ek example hai jisme hum ToolTip ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myButton.Text = "Submit";
myToolTip.AutoPopDelay = 5000;
myToolTip.InitialDelay = 200;
myToolTip.ReshowDelay = 100;
this.Controls.Add(myButton);
this.Controls.Add(myTextBox);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- ToolTip banaya gaya hai jisme ek Button aur TextBox par additional hints dikhaye ja rahe
hain.
- Button par "Click to submit the form data" aur TextBox par "Enter your name here"
ToolTips diye gaye hain.
- ToolTip ko balloon style mein dikhaya gaya hai jisse yeh visually appealing ho jaye.
- Jab user kisi button ya field ka purpose nahi samajh paaye, toh ToolTip us feature ko
explain karne mein madad karta hai. Jaise "Submit" button ka use kya hai, ya "Password"
field mein kya input karna hai.
2. Improving Usability:
- ToolTip ka use UI ko intuitive aur user-friendly banane ke liye hota hai, jisse user
application ko asaani se samajh sake.
3. Providing Hints:
- Complex controls ya icons jahan pe clarity chahiye ho, ToolTip se user ko extra
information provide ki ja sakti hai bina interface ko clutter kiye.
Summary
- ToolTip control ek aisa feature hai jo user ko kisi control ke baare mein additional hints
provide karta hai jab user us control ke upar mouse hover karta hai.
- SetToolTip() method ka use kisi specific control par ToolTip text set karne ke liye hota hai.
ToolTip control Windows Forms mein user experience ko enhance karne mein madad karta
hai. Yeh user ko necessary information provide karta hai bina visual clutter banaye, jisse
application easy to understand aur use ho jati hai.
Timers:
Timer control Windows Forms mein ek useful control hai jiska use scheduled tasks ya
repetitive actions ko execute karne ke liye hota hai. Timer background mein ek event ko
regular intervals par trigger karta hai, jo aapke application mein specific actions perform
karne ke liye helpful hota hai.
- Purpose: Timer ka use repetitive tasks perform karne ke liye hota hai, jaise animation
update karna, progress bar increment karna, ya kisi action ko specific interval par execute
karna.
1. Interval:
- Yeh property specify karti hai ki Timer kitne milliseconds ke delay par tick karega.
- Example:
```csharp
myTimer.Interval = 1000; // Timer har 1000 milliseconds (1 second) par trigger hoga
```
2. Enabled:
- Example:
```csharp
```
3. Tag:
- Yeh property Timer ke saath additional information store karne ke liye use hoti hai.
- Example:
```csharp
myTimer.Tag = "Timer1"; // Timer ko identify karne ke liye ek tag set karta hai
```
1. Start():
- Example:
```csharp
```
2. Stop():
- Example:
```csharp
```
Common Events of Timer
1. Tick:
- Jab Timer interval complete karta hai, toh yeh event trigger hota hai.
- Example:
```csharp
```
Yahan ek example hai jisme hum Timer ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myLabel.AutoSize = true;
this.Controls.Add(myLabel);
this.Controls.Add(startButton);
this.Controls.Add(stopButton);
counter++;
counter = 0;
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- Timer har 1 second ke interval par Tick event trigger karta hai.
- Label mein counter value dikhai jaati hai jo Timer ke har tick par increment hoti hai.
- User ke paas Start aur Stop buttons hain jisse woh Timer ko control kar sakta hai.
1. Periodic Updates:
- Jab aapko kisi UI element ko regular intervals par update karna ho, jaise progress bar,
clock, ya stock prices.
2. Countdown Timer:
- Countdown timer banane ke liye, jahan Timer specific interval par count ko decrement
karta hai.
3. Scheduled Actions:
- Repetitive tasks perform karne ke liye, jaise application ko auto-save karna ya data ko
auto-refresh karna.
- User interface mein animations ya flashing effects banane ke liye Timer ka use hota hai.
Summary
- Timer control Windows Forms mein scheduled ya repetitive actions perform karne ke liye
use hota hai.
- Common properties hain Interval, Enabled, aur common methods hain Start() aur Stop().
- Tick event ka use Timer ke interval complete hone par actions perform karne ke liye hota
hai.
Timer Windows Forms mein kaafi useful control hai jab aapko application mein kisi bhi
cheez ko regularly ya repetitive intervals par execute karna ho. Yeh user experience
improve karta hai aur applications ko dynamic aur responsive banane mein madad karta
hai.
Menus:
Menus Windows Forms applications mein ek important UI element hain jinka use user ko
application mein navigate karne, actions perform karne, ya options select karne ke liye
hota hai. Windows Forms mein commonly used menus hain:
1. MenuStrip: Ek primary control hai jiska use application ke top mein menu bar banane ke
liye hota hai, jismein different options (jaise File, Edit, View) add kiye ja sakte hain.
2. ContextMenuStrip: Ek right-click context menu provide karta hai jisme specific options
hoti hain jo user kisi particular control par right-click karke access karta hai.
1. MenuStrip Control
MenuStrip ek horizontal menu bar hai jismein aap different menus aur submenus add kar
sakte hain. Yeh application ke top par dikhayi deti hai aur user ko application mein
different functionalities ya commands access karne ka option deti hai.
1. Items:
- Example:
```csharp
myMenuStrip.Items.Add(fileMenuItem);
```
2. LayoutStyle:
- Example:
```csharp
myMenuStrip.LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow;
```
- ToolStripMenuItem ek individual item hai jisko aap menu mein add karte hain, jaise
`File`, `Edit`, `Open`, etc.
- Click event ka use jab bhi user kisi menu item par click karta hai tab koi specific action
perform karne ke liye hota hai.
Yahan ek example hai jisme hum MenuStrip ka use kar rahe hain:
```csharp
using System;
using System.Windows.Forms;
public MyForm()
fileMenuItem.DropDownItems.Add(newMenuItem);
fileMenuItem.DropDownItems.Add(openMenuItem);
fileMenuItem.DropDownItems.Add(exitMenuItem);
myMenuStrip.Items.Add(fileMenuItem);
this.MainMenuStrip = myMenuStrip;
this.Controls.Add(myMenuStrip);
[STAThread]
{
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- MenuStrip create kiya gaya hai jisme File menu add kiya gaya hai.
2. ContextMenuStrip Control
1. Items:
- ContextMenuStrip mein different context menu items ko add ya manage karta hai.
- Example:
```csharp
myContextMenuStrip.Items.Add("Cut");
```
# Example: Creating a ContextMenuStrip in Windows Forms
Yahan ek example hai jisme hum ContextMenuStrip ka use kar rahe hain:
```csharp
using System;
using System.Windows.Forms;
public MyForm()
myTextBox.Width = 200;
myTextBox.ContextMenuStrip = myContextMenuStrip;
this.Controls.Add(myTextBox);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- TextBox create kiya gaya hai jisme ek ContextMenuStrip attach kiya gaya hai.
- Jab user TextBox par right-click karta hai, toh yeh context menu options dikhai dete hain
jisse woh text manipulate kar sakta hai.
- ContextMenuStrip ka use tab hota hai jab kisi specific control ke liye quick actions
dikhane ho, jaise right-click menu kisi text box mein cut, copy, paste options dena.
- Menus ka use application mein navigate karne aur user ko application ke different
features access karne mein madad karta hai.
Summary
- MenuStrip ek horizontal menu bar hota hai jo application ke top mein hota hai aur user ko
different menus aur submenus access karne deta hai.
- ContextMenuStrip ek right-click context menu hai jisse specific controls ke liye quick
options provide kiye ja sakte hain.
- Click event ka use menu items par click hone par specific actions perform karne ke liye
hota hai.
Menus Windows Forms applications mein ek important role play karte hain kyunki yeh user
interaction ko easy aur organized banate hain. Yeh user ko application ke features aur
commands ko access karne mein madad karte hain, jisse user experience aur bhi improve
ho jata hai.
2. OpenFileDialog: User ko ek file select karne ke liye dialog provide karta hai.
3. SaveFileDialog: User ko ek file save karne ke liye dialog provide karta hai.
4. ColorDialog: User ko ek color select karne ke liye dialog provide karta hai.
5. FontDialog: User ko ek font select karne ke liye dialog provide karta hai.
6. FolderBrowserDialog: User ko ek folder select karne ke liye dialog provide karta hai.
1. MessageBox
MessageBox ek simple dialog box hai jo user ko message dikhata hai aur optionally button
options provide karta hai, jaise OK, Cancel, Yes, No.
```csharp
```
Is example mein:
- MessageBox ek simple message show karta hai with OK button aur Information icon ke
saath.
2. OpenFileDialog
OpenFileDialog ek dialog box hai jiska use user se ek file open karwane ke liye hota hai.
Yeh dialog user ko system directories explore karne aur ek file select karne ka option deta
hai.
- File type filter set karta hai jisse user ko specific file types select karne ka option mile.
- Example:
```csharp
```
2. InitialDirectory:
- Example:
```csharp
openFileDialog.InitialDirectory = @"C:\";
```
```csharp
if (openFileDialog.ShowDialog() == DialogResult.OK)
```
3. SaveFileDialog
SaveFileDialog ek dialog box hai jiska use user se ek file save karwane ke liye hota hai. Yeh
dialog user ko file ka naam aur location specify karne ka option deta hai.
```csharp
if (saveFileDialog.ShowDialog() == DialogResult.OK)
```
4. ColorDialog
ColorDialog ek dialog box hai jiska use user se ek color select karwane ke liye hota hai. Yeh
control application mein kisi background ya control ka color change karne ke liye useful
hota hai.
if (colorDialog.ShowDialog() == DialogResult.OK)
```
5. FontDialog
FontDialog ek dialog box hai jiska use user se ek font select karwane ke liye hota hai. Yeh
dialog text styling ya formatting ke liye useful hota hai.
```csharp
if (fontDialog.ShowDialog() == DialogResult.OK)
```
6. FolderBrowserDialog
FolderBrowserDialog ek dialog box hai jiska use user se ek folder select karwane ke liye
hota hai. Yeh dialog folder selection ke liye use hota hai, jaise file ko kisi specific folder
mein save karna ya kisi directory ko select karna.
```csharp
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
```
Printing:
Printing in Windows Forms applications mein ek feature hai jiska use content ko physically
print karne ke liye hota hai, jaise documents, invoices, images, ya kisi bhi UI element ko
printer se output ke roop mein generate karna. Windows Forms mein printing ke liye kaafi
classes aur dialogs available hain, jo printing process ko simplify karte hain.
2. PrintDialog: Dialog box jo user ko print preferences set karne ka option deta hai.
3. PageSetupDialog: Page setup options jaise margins, paper size, orientation set karne ke
liye dialog box.
4. PrintPreviewDialog: Print preview show karne ke liye dialog box jisse user print output ko
pehle se dekh sake.
1. PrintDocument Class
PrintDocument class printing ko manage karne ka main component hai. Yeh class
PrintPage event ko handle karti hai, jisme aap specify karte hain ki kya print karna hai aur
kaise print karna hai.
using System;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
public MyForm()
myPrintDocument.PrintPage += new
PrintPageEventHandler(PrintDocument_PrintPage);
this.Controls.Add(printButton);
}
printDialog.Document = myPrintDocument;
if (printDialog.ShowDialog() == DialogResult.OK)
// PrintPage event mein specify karte hain kya print karna hai
[STAThread]
{
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- PrintDocument create kiya gaya hai jo PrintPage event ko handle karta hai.
- PrintDialog show hota hai jab user Print button par click karta hai, aur agar user OK karta
hai toh Print method call hoti hai.
- PrintPage event ke through, `e.Graphics.DrawString()` ka use karke specify kiya gaya hai
ki print par kya output aayega.
2. PrintDialog
PrintDialog ek dialog box hai jiska use user se printing preferences set karwane ke liye hota
hai. Yeh dialog user ko printer select karne, page range define karne, ya copies set karne ka
option deta hai.
```csharp
printDialog.Document = myPrintDocument;
if (printDialog.ShowDialog() == DialogResult.OK)
{
myPrintDocument.Print();
```
3. PageSetupDialog
PageSetupDialog ek dialog box hai jiska use user se page settings set karwane ke liye hota
hai, jaise paper size, margins, aur orientation. Yeh dialog box printing se pehle page ka
layout set karne mein madad karta hai.
```csharp
pageSetupDialog.Document = myPrintDocument;
if (pageSetupDialog.ShowDialog() == DialogResult.OK)
```
4. PrintPreviewDialog
PrintPreviewDialog ek dialog box hai jo user ko print output preview dikhata hai taaki woh
dekh sake ki printout kaisa dikhega. Yeh dialog user ko print karne se pehle output verify
karne ka option deta hai.
# Example: Using PrintPreviewDialog
```csharp
printPreviewDialog.Document = myPrintDocument;
```
1. Page Setup (Optional): User PageSetupDialog ke through page layout set karta hai.
3. Print Dialog: PrintDialog ke through user printer aur copies select karta hai.
4. Printing: PrintDocument ke PrintPage event mein content define karke Print() method
call hoti hai.
Summary
1. PrintDocument:
- Printing process ko handle karta hai aur PrintPage event mein content define karta hai.
2. PrintDialog:
- User ko printer aur print preferences set karne ka option deta hai.
3. PageSetupDialog:
- Page settings jaise margins, paper size set karne ke liye use hota hai.
4. PrintPreviewDialog:
- Print preview dikhane ke liye, jisse user dekh sake ki print kaisa dikhega.
Printing Windows Forms applications mein kaafi common requirement hai, jiska use
invoices, documents, ya kisi bhi content ko physical print output mein convert karne ke liye
hota hai. Built-in classes aur dialogs printing ko easy aur user-friendly banate hain, jisse
user application ke content ko asaani se print kar sake.
Image Lists:
ImageList control Windows Forms mein ek collection hai jisme multiple images ko store
kiya ja sakta hai. ImageList ka use tab hota hai jab aapko application mein different
controls ke saath images associate karni ho, jaise buttons, list views, tree views, ya
toolbars. Yeh ek convenient tarika hai jisse aap images ko ek jagah store karke baar-baar
use kar sakte hain.
- Namespace: `System.Windows.Forms`
- Purpose: ImageList ka use ek collection mein multiple images ko store karne aur unhe
baar-baar alag controls mein use karne ke liye hota hai.
- Common Use Cases: Buttons ke icons, ListView ya TreeView mein items ke saath images
add karna, toolbar buttons par icons show karna.
1. Images:
- ImageList mein stored images ko manage karta hai. Yeh ek collection hai jisme aap
images add ya remove kar sakte hain.
- Example:
```csharp
myImageList.Images.Add(Image.FromFile("path/to/image1.png"));
```
2. ImageSize:
- ImageList mein stored images ki size set karta hai. Default size `16x16` pixels hota hai,
lekin aap isse customize kar sakte hain.
- Example:
```csharp
myImageList.ImageSize = new Size(32, 32); // Image size 32x32 pixels set karta hai
```
3. ColorDepth:
- Example:
```csharp
```
1. Images.Add():
- Example:
```csharp
myImageList.Images.Add(Image.FromFile("path/to/image.png"));
```
2. Images.RemoveAt():
- Example:
```csharp
```
3. Images.Clear():
- Example:
```csharp
```
ImageList ko commonly ListView, TreeView, ya Button jaison ke saath use kiya jaata hai
taaki unmein images ya icons add kiye ja saken.
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myImageList.Images.Add(Image.FromFile("path/to/image1.png"));
myImageList.Images.Add(Image.FromFile("path/to/image2.png"));
myListView.View = View.LargeIcon;
myListView.LargeImageList = myImageList;
// ListView mein items add karte hain aur unhein images assign karte hain
ListViewItem item1 = new ListViewItem("Item 1", 0); // Index 0 par stored image assign
karta hai
ListViewItem item2 = new ListViewItem("Item 2", 1); // Index 1 par stored image assign
karta hai
myListView.Items.Add(item1);
myListView.Items.Add(item2);
this.Controls.Add(myListView);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- ImageList create kiya gaya hai jisme do images add ki gayi hain.
- ListView control mein items add kiye gaye hain aur ImageList se images assign ki gayi
hain.
- ListView ke items ke saath images bhi show ho rahe hain, jahan each item ek specific
image se linked hai.
- ImageList ka use ListView control mein har item ke saath ek image add karne ke liye
hota hai. Yeh Explorer-style lists banane mein kaafi useful hai jahan har item ka icon ho.
- ImageList TreeView mein nodes ke saath icons associate karne mein use hota hai, jisse
hierarchical structures visually aur bhi samajhne mein easy ho jaate hain.
- ImageList ka use toolbars ya buttons par icons dikhane ke liye bhi hota hai, jisse
application visually attractive aur user-friendly lagti hai.
Summary
- ImageList ek collection control hai jo multiple images ko ek jagah store karke unhe
controls ke saath baar-baar use karne mein help karta hai.
- Common Properties hain Images, ImageSize, ColorDepth, jo images ko store aur manage
karne mein madad karte hain.
- ImageList ko ListView, TreeView, aur Buttons jaison ke saath use karke UI mein visual
elements add kiye ja sakte hain.
ImageList control Windows Forms applications mein kaafi useful hota hai jab aapko ek
centralized collection mein images rakhkar unhein application ke different controls mein
reuse karna ho. Yeh approach not only efficient hai, but UI ko visually appealing aur
consistent bhi banata hai.
1. TreeView Control
TreeView ek hierarchical structure mein data ko dikhane ka control hai. Yeh ek tree-like
structure provide karta hai jisme nodes hoti hain jo expand ya collapse ki ja sakti hain, jisse
user different levels ya sub-items ko dekh sakta hai.
1. Nodes:
- TreeView ke andar root nodes aur child nodes ko represent karta hai.
- Example:
```csharp
```
2. ImageList:
- TreeView ke nodes ke saath icons add karne ke liye use hoti hai.
- Example:
```csharp
```
3. SelectedNode:
- Example:
```csharp
```
1. AfterSelect:
- Jab user kisi node ko select karta hai, toh yeh event trigger hota hai.
- Example:
```csharp
```
```csharp
using System;
using System.Windows.Forms;
public MyForm()
rootNode.Nodes.Add(childNode1);
rootNode.Nodes.Add(childNode2);
myTreeView.Nodes.Add(rootNode);
this.Controls.Add(myTreeView);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- TreeView control mein ek root node aur do child nodes add kiye gaye hain.
- AfterSelect event ke through, selected node ka text MessageBox mein dikhaya jaata hai.
1. File Explorer:
- Folder structure dikhane ke liye jahan folders aur subfolders hierarchical view mein
dikhai dete hain.
2. Organizational Structure:
3. Navigation Menus:
2. ListView Control
ListView ek control hai jisme items ko list format mein dikhaya jaata hai, jisme icons,
details, ya tiles format mein data dikhaya ja sakta hai. Yeh control tab use hota hai jab data
ko tabular ya list ke form mein organize karke dikhana ho.
1. View:
- Example:
```csharp
```
2. Columns:
- ListView mein columns add karta hai jab view mode Details ho.
- Example:
```csharp
```
3. Items:
- Example:
```csharp
```
# Common Events of ListView
1. SelectedIndexChanged:
- Jab user kisi naya item ko select karta hai, toh yeh event trigger hota hai.
- Example:
```csharp
myListView.SelectedIndexChanged += new
EventHandler(MyListView_SelectedIndexChanged);
if (myListView.SelectedItems.Count > 0)
```
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myListView.View = View.Details;
myListView.Columns.Add("Name", 100);
myListView.Columns.Add("Age", 50);
myListView.SelectedIndexChanged += new
EventHandler(MyListView_SelectedIndexChanged);
this.Controls.Add(myListView);
}
private void MyListView_SelectedIndexChanged(object sender, EventArgs e)
if (myListView.SelectedItems.Count > 0)
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- ListView control mein `Details` view use kiya gaya hai, jisme columns (`Name` aur
`Age`) aur items add kiye gaye hain.
- Files aur folders ko alag-alag views (large icons, small icons, details) mein dikhane ke
liye.
2. Contact Lists:
- Contacts ko list format mein details ke saath dikhane ke liye jaise naam, phone number,
etc.
3. Data Presentation:
- Kisi bhi list ya tabular data ko represent karne ke liye jaise inventory, product lists, etc.
Summary
- TreeView hierarchical data ko dikhata hai jahan nodes ko expand/collapse karke sub-
items dekh sakte hain.
- ListView tabular ya list format mein data ko dikhata hai jisme multiple views ho sakte hain
(details, icons).
- TreeView aur ListView dono ke saath ImageList ka use kiya ja sakta hai, jisse items ke
saath icons add kiye ja sake.
TreeView aur ListView Windows Forms applications mein kaafi powerful aur useful
controls hain jo data ko well-organized aur user-friendly tarike se dikhane mein madad
karte hain. Yeh controls user experience ko enhance karte hain aur data presentation ko
better banate hain.
Toolbars:
Toolbars Windows Forms mein ek graphical control hai jiska use commonly used
commands aur actions ko provide karne ke liye hota hai, jisse user asaani se in commands
ko access kar sake. Toolbar mein ek collection of buttons hoti hain jinko icons ya text se
represent kiya ja sakta hai. Yeh application ke top ya bottom mein add kiya ja sakta hai, aur
user interface ko interactive aur easy-to-use banata hai.
ToolStrip Control
ToolStrip ek updated control hai jiska use Windows Forms applications mein toolbar
functionalities provide karne ke liye hota hai. Yeh ToolBar control se zyada advanced hai
aur zyada customization aur flexibility provide karta hai.
2. ToolStripSeparator: Ek line jo buttons ko visually separate karne ke liye use hoti hai.
4. ToolStripLabel: Label jiska use text display karne ke liye hota hai.
1. Items:
- ToolStrip mein different elements add karne ke liye use hota hai jaise buttons, labels.
- Example:
```csharp
myToolStrip.Items.Add(new ToolStripButton("New"));
myToolStrip.Items.Add(new ToolStripSeparator());
```
2. Dock:
- Yeh property ToolStrip ko parent container mein kis position mein dock karna hai specify
karti hai. Default hota hai `Top`.
- Example:
```csharp
myToolStrip.Dock = DockStyle.Top;
```
Yahan ek example hai jisme hum ToolStrip ka use kar rahe hain:
```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
public MyForm()
myToolStrip.Items.Add(newButton);
myToolStrip.Items.Add(openButton);
myToolStrip.Items.Add(separator);
myToolStrip.Items.Add(saveButton);
this.Controls.Add(myToolStrip);
}
private void NewButton_Click(object sender, EventArgs e)
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- ToolStrip create kiya gaya hai jisme `New`, `Open`, aur `Save` buttons add kiye gaye
hain.
- ToolStripSeparator buttons ke beech mein add kiya gaya hai taaki options visually
separate ho jayein.
- Click events ko handle karke har button par ek specific action perform kiya gaya hai.
- Toolbars ka use user ko common commands (jaise `New`, `Open`, `Save`, `Print`)
tak quick access dene ke liye hota hai. Yeh actions user ke liye easily accessible hote hain
jisse unka kaam jaldi hota hai.
- ToolStrip mein buttons ke saath icons add kiye ja sakte hain taaki user asaani se
recognize kar sake ki button ka use kya hai. Jaise ek save button par ek floppy disk icon, ya
open button par ek folder icon.
- ToolStripButton mein icons ke saath text bhi dikhaya ja sakta hai jisse button ka function
clear ho jaye.
Customizing ToolStrip
- Images ko buttons ke saath add karne ke liye ToolStripButton ki Image property set ki ja
sakti hai.
- Example:
```csharp
saveButton.Image = Image.FromFile("path/to/icon.png");
saveButton.Text = "Save";
```
2. ToolStripDropDownButton:
- Yeh button ek drop-down menu ke saath hota hai jisme multiple options ho sakte hain.
- Example:
```csharp
optionsButton.DropDownItems.Add("Option 1");
optionsButton.DropDownItems.Add("Option 2");
myToolStrip.Items.Add(optionsButton);
```
Summary
- Toolbars user ko common actions aur commands tak quick access provide karne ka ek
tarika hain. Windows Forms mein toolbar implement karne ke liye ToolStrip control ka use
hota hai.
- ToolStrip mein elements add kiye ja sakte hain, jaise ToolStripButton, ToolStripSeparator,
aur ToolStripDropDownButton, jisse user interface organized aur user-friendly ban jaye.
- ToolStripButton ke saath Click events ko handle karke specific actions perform kiye ja
sakte hain.
- Toolbars ka use application mein actions ko quickly accessible aur intuitive banata hai,
jisse user experience improve hota hai.
Toolbars Windows Forms applications mein kaafi useful hain kyunki yeh commands ko
asaani se accessible banate hain aur application ke workflow ko improve karte hain.
ToolStrip ka use karke aap ek highly customizable toolbar bana sakte hain jo user interface
mein seamlessly integrate ho jata hai.
Status Bars, Progress Bars, aur Tab Controls Windows Forms mein commonly used UI
components hain jo user interface ko improve karte hain, aur user ko application ke
current status, progress, ya different views provide karte hain. Yeh controls user
experience ko kaafi enhance karte hain aur application ko more interactive banate hain.
1. StatusBar Control
StatusBar ek horizontal bar hai jo Windows Forms application ke bottom mein dikhai deti
hai, jiska use application ke current status, messages, ya short information display karne
ke liye hota hai. Modern Windows Forms applications mein StatusStrip ka use kiya jata hai
jo ek updated version hai StatusBar ka aur zyada customization options provide karta hai.
1. ToolStripStatusLabel: Status strip mein label jisme text ya information display ki ja sakti
hai.
using System;
using System.Windows.Forms;
public MyForm()
myStatusStrip.Items.Add(statusLabel);
this.Controls.Add(myStatusStrip);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
}
```
Is example mein:
- StatusStrip create kiya gaya hai jisme ek ToolStripStatusLabel add kiya gaya hai jisme
"Ready" text show hota hai.
- User actions ke baad updates dene ke liye, jaise "File saved successfully".
2. ProgressBar Control
ProgressBar control Windows Forms mein ek indicator hai jo kisi ongoing process ya task ki
progress show karta hai, jise loading, file transfer, ya data processing ki progress. Yeh ek
graphical representation hai jisse user ko pata chal sake ki process kitna complete ho
chuka hai.
1. Minimum:
- Progress bar ki starting value set karta hai. Default value `0` hoti hai.
- Example:
```csharp
myProgressBar.Minimum = 0;
```
2. Maximum:
- Progress bar ki ending value set karta hai. Default value `100` hoti hai.
- Example:
```csharp
myProgressBar.Maximum = 100;
```
3. Value:
- Example:
```csharp
```
```csharp
using System;
using System.Windows.Forms;
public MyForm()
myProgressBar.Width = 200;
myProgressBar.Minimum = 0;
myProgressBar.Maximum = 100;
this.Controls.Add(myProgressBar);
this.Controls.Add(startButton);
{
myProgressBar.Value = 50; // Example: progress ko 50% set karte hain
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- ProgressBar create kiya gaya hai jiska value `50` (50% complete) set hota hai jab Start
button click hota hai.
2. Loading Screens:
3. TabControl
TabControl ek control hai jiska use tabbed interface create karne ke liye hota hai, jahan
user multiple pages ya sections ko ek hi window mein navigate kar sakta hai. Tabs ko
logically related sections ko organize karne ke liye use kiya jaata hai.
1. TabPage: TabControl mein har tab ko represent karta hai, jisme different controls aur
content ho sakta hai.
```csharp
using System;
using System.Windows.Forms;
public MyForm()
myTabControl.TabPages.Add(tabPage1);
myTabControl.TabPages.Add(tabPage2);
this.Controls.Add(myTabControl);
[STAThread]
Application.EnableVisualStyles();
Application.Run(new MyForm());
```
Is example mein:
- TabControl create kiya gaya hai jisme do tabs (`Tab 1` aur `Tab 2`) add kiye gaye hain.
- Har tab ek TabPage ko represent karta hai jisme alag content ho sakta hai.
- Ek form mein multiple sections ko organize karne ke liye jahan ek tab par user profile
settings ho aur doosre tab par security settings ho.
2. Data Categorization:
- Ek application mein alag-alag categories ko logically alag rakhne ke liye jaise Product
Details, Reviews, Specifications.
Summary
- StatusStrip ka use application ke current status ya messages display karne ke liye hota
hai.
2. Progress Bars:
3. Tab Controls:
- TabControl ek tabbed interface create karta hai jisme multiple pages ya sections hoti
hain.
Status Bars, Progress Bars, aur Tab Controls application ke UI ko interactive aur user-
friendly banane mein important role play karte hain. Yeh controls application mein clarity,
organization, aur better user interaction provide karte hain, jisse application ki usability
improve hoti hai.