0% found this document useful (0 votes)
62 views197 pages

Bca 5th Sem .Net 3rd Unit

Bca 3rd unit. Net

Uploaded by

muskanpatel1784
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views197 pages

Bca 5th Sem .Net 3rd Unit

Bca 3rd unit. Net

Uploaded by

muskanpatel1784
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 197

SEMESTER- V

5BCA1 –DOT NET PROGRAMMING WITH VB.NET &


ASP.NET
Unit 3

.NET Tools:

1. Visual Studio

- Type: IDE (Integrated Development Environment)

- Description: Yeh ek primary tool hai .NET development ke liye. Isme debugging, testing,
version control, aur deployment jaisi saari suvidhaayein milti hain.

- Features:

- Code likhne mein madad karta hai (IntelliSense).

- Bugs find karne aur fix karne ka option hota hai (Integrated Debugger).

- Bahut saari plugins aur extensions available hain.

2. Visual Studio Code (VS Code)

- Type: Lightweight Code Editor

- Description: Yeh ek lightweight code editor hai, jisme .NET ke liye C# extension use kiya
ja sakta hai. Cross-platform support karta hai.

- Features:

- Debugging aur terminal in-built hain.

- Extensions ka use karke functionality badhai ja sakti hai.


3. .NET CLI (Command Line Interface)

- Type: Command-Line Tool

- Description: .NET CLI command line se projects create, build, run, aur publish karne ke
liye use hota hai.

- Commands:

- `dotnet new` - Naya project create karta hai.

- `dotnet build` - Project ko compile karta hai.

- `dotnet run` - Project ko run karta hai.

- `dotnet test` - Test run karta hai.

4. NuGet

- Type: Package Manager

- 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

- Type: Visual Studio Extension

- 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:

- Code ko easily navigate aur refactor kar sakte hain.

- Code quality analysis ke tools provide karta hai.


6. Entity Framework Tools

- Type: ORM Tool

- Description: Entity Framework ek Object Relational Mapper hai jo .NET mein database
ke saath interact karne mein madad karta hai.

- Commands:

- `dotnet ef migrations add <MigrationName>` - Nayi migration add karta hai.

- `dotnet ef database update` - Database schema update karta hai.

7. Fiddler

- Type: Network Debugging Proxy

- 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

- Type: API Testing Tool

- Description: APIs ko test karne ke liye use hota hai. HTTP requests ko easily create aur
test kar sakte hain.

9. dotMemory, dotTrace, dotCover (JetBrains ke tools)

- Type: Profiling aur Testing Tools

- Description:

- dotMemory: Memory profiling karne ke liye.

- dotTrace: Performance profiling karne ke liye.

- dotCover: Unit tests ki coverage ko measure karta hai.

10. Azure DevOps

- Type: CI/CD aur Project Management Tool


- Description: Azure DevOps ek suite hai jisme aap software lifecycle ko manage kar
sakte hain - version control, CI/CD pipelines, aur project tracking sab kuch yahan milta hai.

11. Docker

- Type: Containerization Tool

- 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

- Type: Deployment Engine (Azure mein use hota hai)

- Description: Yeh Azure App Services ka deployment engine hai jisse aap Git
deployments manage kar sakte hain.

13. Swagger aur Swashbuckle

- Type: API Documentation Tool

- Description: Swagger API documentation generate karta hai. Swashbuckle ASP.NET


Core se Swagger ko integrate karta hai.

- Usage: Automatically interactive documentation generate karta hai APIs ke liye.

14. SonarQube

- Type: Static Code Analysis Tool

- Description: Code quality analyze karta hai, bugs aur vulnerabilities detect karta hai,
aur CI/CD pipelines mein integrate hota hai.

15. GitHub Actions

- Type: CI/CD Tool


- Description: GitHub Actions se aap apne workflows automate kar sakte hain, jaise
build, test, aur deployment processes.

16. PowerShell

- Type: Automation Tool

- Description: PowerShell scripting aur automation ke liye use hota hai. Aap deployment
aur administrative tasks automate kar sakte hain.

17. MSBuild

- Type: Build Automation Tool

- Description: MSBuild .NET projects ko build karne ke liye default tool hai.

- Usage: `msbuild MyProject.csproj` command se project ko build kar sakte hain.

18. LINQPad

- Type: Interactive Query Tool

- Description: LINQPad ek powerful tool hai jisse aap databases ko interactively query
kar sakte hain LINQ se, bina poora project banaye.

Summary

- Development & Debugging: Visual Studio, VS Code, ReSharper.

- Command Line & Build Tools: .NET CLI, MSBuild.

- Package Management: NuGet.

- Testing: dotCover, Postman, Swagger.

- Memory & Performance Profiling: dotMemory, dotTrace.

- CI/CD & Deployment: Azure DevOps, GitHub Actions, Docker.

- Automation: PowerShell.

- API Management: Swagger, Postman.


- Analysis: SonarQube.

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

- Control class sabhi UI components ka foundation hai Windows Forms mein.

- 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.

Commonly Used Properties

`Control` class mein kai properties hain jisse aap controls ka appearance aur behavior
manage kar sakte hain:

1. Name: Control ka naam set ya get karta hai.

```csharp
control.Name = "myControl";

```

2. Text: Control se juda hua text set ya get karta hai.

```csharp

myButton.Text = "Click Me!";

```

3. Location: Control ki (x, y) coordinates ko specify karta hai jo container ke hisaab se hoti
hain.

```csharp

myLabel.Location = new Point(50, 100);

```

4. Size: Control ki height aur width set karta hai.

```csharp

myTextBox.Size = new Size(200, 30);

```

5. BackColor: Control ka background color set karta hai.

```csharp

myButton.BackColor = Color.LightBlue;

```

6. ForeColor: Text ka color set karta hai.

```csharp
myLabel.ForeColor = Color.Red;

```

7. Enabled: Yeh batata hai ki control user input ko respond kar sakta hai ya nahi.

```csharp

myButton.Enabled = false; // Button disable ho gaya

```

8. Visible: Yeh control ko dikhata ya chhupata hai.

```csharp

myTextBox.Visible = true; // Text box dikhega

```

9. Anchor aur Dock: Control ka size kaise resize ho usko control karta hai.

```csharp

myPanel.Dock = DockStyle.Fill; // Container ko fill kar lega

myButton.Anchor = AnchorStyles.Top | AnchorStyles.Left; // Top-left se anchor ho jayega

```

Common Methods

`Control` class mein kuch common methods bhi hain jisse aap controls ko manage aur
interact kar sakte hain:

1. Show() aur Hide(): Control ko dikhane ya chhupane ke liye.

```csharp

myControl.Show();
myControl.Hide();

```

2. Focus(): Control par input focus set karta hai.

```csharp

myTextBox.Focus();

```

3. Invalidate(): Control ko redraw karne ke liye force karta hai.

```csharp

myPanel.Invalidate();

```

4. BringToFront() aur SendToBack(): Z-order adjust karta hai (matlab controls ke upar ya
neeche dikhne ka order).

```csharp

myButton.BringToFront(); // Button ko sabse upar le aata hai

myLabel.SendToBack(); // Label ko sabke peeche bhej deta hai

```

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

myButton.Click += new EventHandler(Button_Click);


```

2. MouseHover: Jab mouse pointer control ke upar hover karta hai toh trigger hota hai.

```csharp

myLabel.MouseHover += new EventHandler(Label_MouseHover);

```

3. KeyPress: Jab control ke upar focus ho aur koi key press ki jaye toh trigger hota hai.

```csharp

myTextBox.KeyPress += new KeyPressEventHandler(TextBox_KeyPress);

```

4. Paint: Jab control ko redraw ki zaroorat ho toh trigger hota hai.

```csharp

myPanel.Paint += new PaintEventHandler(Panel_Paint);

```

Derived Classes

Control class se bohot saare controls inherit karte hain, jaise:

- Button: Ek clickable button hai.

- TextBox: User input ke liye text box.

- Label: Text display karta hai jo edit nahi ho sakta.

- ComboBox: Ek dropdown list provide karta hai.

- Panel: Ek container hai jo aur controls ko group karta hai.


Example

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 class MyForm : Form

private Button myButton;

private TextBox myTextBox;

public MyForm()

// Button control create aur configure karte hain

myButton = new Button();

myButton.Text = "Click Me!";

myButton.Location = new Point(50, 50);

myButton.Click += new EventHandler(MyButton_Click);

// TextBox control create aur configure karte hain

myTextBox = new TextBox();

myTextBox.Location = new Point(50, 100);

myTextBox.Size = new Size(200, 30);


// Form mein controls add karte hain

this.Controls.Add(myButton);

this.Controls.Add(myTextBox);

private void MyButton_Click(object sender, EventArgs e)

myTextBox.Text = "Button Clicked!";

[STAThread]

public static void Main()

Application.EnableVisualStyles();

Application.Run(new MyForm());

```

Is example mein:

- Button aur TextBox `Control` class se derived hain.

- Button ke Click event se textbox ka text change hota hai.

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.

Key Features of TextBox

- Namespace: `System.Windows.Forms`

- Purpose: User input ya text display karne ke liye.

- Common Use Cases: User se naam, address, comments, password wagaira lena.

Common Properties of TextBox

1. Text:
- `Text` property mein `TextBox` ka andar ka text store hota hai.

- Example:

```csharp

myTextBox.Text = "Hello World!";

```

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:

- Text ko replace karta hai kisi symbol se (password input ke liye).

- Example:

```csharp

myTextBox.PasswordChar = '*'; // Har character '*' ki tarah dikhai dega.


```

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;

```

Common Methods of TextBox

1. Clear():

- `TextBox` ke andar ka saara text clear karta hai.

- Example:

```csharp

myTextBox.Clear();

```

2. AppendText():

- Current text ke end mein kuch aur text add karta hai.

- Example:

```csharp

myTextBox.AppendText(" - Additional Text");

```

Common Events of TextBox

1. TextChanged:

- Jab bhi `TextBox` ka text change ho, toh yeh event trigger hota hai.

- Example:

```csharp

myTextBox.TextChanged += new EventHandler(MyTextBox_TextChanged);


private void MyTextBox_TextChanged(object sender, EventArgs e)

Console.WriteLine("Text changed: " + myTextBox.Text);

```

2. KeyPress:

- Jab `TextBox` par focus ho aur koi key press ho, tab trigger hota hai.

- Example:

```csharp

myTextBox.KeyPress += new KeyPressEventHandler(MyTextBox_KeyPress);

private void MyTextBox_KeyPress(object sender, KeyPressEventArgs e)

if (!char.IsLetterOrDigit(e.KeyChar) && !char.IsControl(e.KeyChar))

e.Handled = true; // Sirf letters, digits, aur control keys allow honge.

```

3. Enter and Leave:

- 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

myTextBox.Enter += (s, e) => myTextBox.BackColor = Color.LightYellow;

myTextBox.Leave += (s, e) => myTextBox.BackColor = Color.White;

```

Example: Using TextBox in Windows Forms

Yahan ek example hai jisme hum `TextBox` use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private TextBox myTextBox;

private Button myButton;

public MyForm()

// TextBox create aur configure karte hain

myTextBox = new TextBox();

myTextBox.Location = new Point(50, 50);

myTextBox.Size = new Size(200, 30);

myTextBox.MaxLength = 100;
myTextBox.Multiline = true;

myTextBox.ScrollBars = ScrollBars.Vertical;

// Button create karte hain jo TextBox ka text show karega

myButton = new Button();

myButton.Text = "Show Text";

myButton.Location = new Point(50, 100);

myButton.Click += new EventHandler(MyButton_Click);

// Form mein TextBox aur Button add karte hain

this.Controls.Add(myTextBox);

this.Controls.Add(myButton);

private void MyButton_Click(object sender, EventArgs e)

MessageBox.Show("TextBox Content: " + myTextBox.Text);

[STAThread]

public static void Main()

Application.EnableVisualStyles();

Application.Run(new MyForm());

}
```

Is example mein:

- Humne ek `TextBox` banaya jo user se input leta hai.

- Ek `Button` bhi banaya jo `TextBox` ke andar ka content show karta hai.

Summary

- TextBox control use hota hai user input lene ya text display karne ke liye.

- Yeh multiline, password input, read-only, wagaira support karta hai.

- 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.

Common Properties of RichTextBox


1. Rtf:

- Rich Text Format (RTF) ko get/set karta hai. Yeh text ko formatting ke saath store karta
hai.

- Example:

```csharp

string rtfContent = myRichTextBox.Rtf; // Rich Text ko get karna

myRichTextBox.Rtf = rtfContent; // Rich Text set karna

```

2. Text:

- Plain text jo `RichTextBox` mein likha gaya hai.

- Example:

```csharp

myRichTextBox.Text = "Hello RichTextBox!";

```

3. SelectionFont:

- Selected text ka font change karta hai.

- Example:

```csharp

myRichTextBox.SelectionFont = new Font("Arial", 12, FontStyle.Bold);

```

4. SelectionColor:

- Selected text ka color change karta hai.


- Example:

```csharp

myRichTextBox.SelectionColor = Color.Red; // Selected text red ho jayega

```

5. SelectionBackColor:

- Selected text ka background color set karta hai.

- Example:

```csharp

myRichTextBox.SelectionBackColor = Color.Yellow; // Highlight karega yellow se

```

6. DetectUrls:

- URLs ko detect karke unko clickable links mein convert karta hai.

- Example:

```csharp

myRichTextBox.DetectUrls = true; // URLs ko clickable link bana dega

```

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

myRichTextBox.ScrollBars = RichTextBoxScrollBars.Both; // Horizontal aur Vertical dono


scroll bars

```

Common Methods of RichTextBox

1. AppendText():

- Text add karta hai `RichTextBox` ke end mein.

- Example:

```csharp

myRichTextBox.AppendText(" - New Content Added");

```

2. LoadFile():

- RTF ya plain text file load karta hai `RichTextBox` mein.

- 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);

```

Common Events of RichTextBox

1. TextChanged:

- Jab `RichTextBox` ka content change ho jaye, toh yeh event trigger hota hai.

- Example:

```csharp

myRichTextBox.TextChanged += new EventHandler(MyRichTextBox_TextChanged);

private void MyRichTextBox_TextChanged(object sender, EventArgs e)

Console.WriteLine("RichTextBox content changed!");

```

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)

System.Diagnostics.Process.Start(e.LinkText); // URL ko browser mein open karega

```

Example: Using RichTextBox in Windows Forms

Yeh ek example hai jisme hum ek RichTextBox ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private RichTextBox myRichTextBox;

private Button myButton;

public MyForm()

// RichTextBox create aur configure karte hain

myRichTextBox = new RichTextBox();

myRichTextBox.Location = new Point(20, 20);


myRichTextBox.Size = new Size(300, 150);

myRichTextBox.SelectionFont = new Font("Verdana", 12);

myRichTextBox.SelectionColor = Color.Blue;

// Button create karte hain taaki formatting add kar sake

myButton = new Button();

myButton.Text = "Bold Text";

myButton.Location = new Point(20, 200);

myButton.Click += new EventHandler(MyButton_Click);

// Form mein RichTextBox aur Button add karte hain

this.Controls.Add(myRichTextBox);

this.Controls.Add(myButton);

private void MyButton_Click(object sender, EventArgs e)

myRichTextBox.SelectionFont = new Font(myRichTextBox.SelectionFont,


FontStyle.Bold);

[STAThread]

public static void Main()

Application.EnableVisualStyles();

Application.Run(new MyForm());
}

```

Is example mein:

- Humne ek RichTextBox banaya jo user ko formatted text likhne deta hai.

- Ek button banaya jisse selected text ko bold kiya ja sakta hai.

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.

Common Properties of Label

1. Text:

- Yeh `Label` ke andar display hone wala text set ya get karta hai.

- Example:

```csharp

myLabel.Text = "Enter your name:";

```

2. Font:

- Yeh label ke text ka font set karta hai.

- Example:

```csharp

myLabel.Font = new Font("Arial", 12, FontStyle.Bold);

```

3. ForeColor:

- Label text ka color set karta hai.

- Example:
```csharp

myLabel.ForeColor = Color.Blue;

```

4. BackColor:

- Label ke background ka color set karta hai.

- 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

myLabel.AutoSize = true; // Text ke size ke hisaab se label ka size adjust ho jayega

```

6. TextAlign:

- Text ka alignment set karta hai label mein.

- Example:

```csharp

myLabel.TextAlign = ContentAlignment.MiddleCenter; // Center mein align karega text


ko

```
7. BorderStyle:

- Label ke border ka style set karta hai. Options hain `None`, `FixedSingle`, aur
`Fixed3D`.

- Example:

```csharp

myLabel.BorderStyle = BorderStyle.FixedSingle;

```

Common Methods of Label

Labels ke saath methods zyada nahi hain kyunki unka kaam sirf text display karna hota hai,
lekin kuch useful methods hain:

1. Refresh():

- Label ko redraw karta hai jab text ya property change ho.

- Example:

```csharp

myLabel.Refresh();

```

Common Events of Label

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

myLabel.Click += new EventHandler(MyLabel_Click);

private void MyLabel_Click(object sender, EventArgs e)

MessageBox.Show("Label clicked!");

```

2. MouseEnter and MouseLeave:

- 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

myLabel.MouseEnter += (s, e) => myLabel.ForeColor = Color.Red; // Mouse aane par text


red ho jayega

myLabel.MouseLeave += (s, e) => myLabel.ForeColor = Color.Black; // Mouse jaane par


text black ho jayega

```

Example: Using Label in Windows Forms

Yahan ek example hai jisme hum Label control use kar rahe hain:

```csharp
using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private Label myLabel;

private TextBox myTextBox;

private Button myButton;

public MyForm()

// Label create aur configure karte hain

myLabel = new Label();

myLabel.Text = "Enter your name:";

myLabel.Location = new Point(20, 20);

myLabel.Font = new Font("Arial", 10, FontStyle.Regular);

myLabel.AutoSize = true;

// TextBox create karte hain

myTextBox = new TextBox();

myTextBox.Location = new Point(20, 50);

myTextBox.Size = new Size(200, 25);

// Button create karte hain

myButton = new Button();


myButton.Text = "Submit";

myButton.Location = new Point(20, 90);

myButton.Click += new EventHandler(MyButton_Click);

// Form mein Label, TextBox, aur Button add karte hain

this.Controls.Add(myLabel);

this.Controls.Add(myTextBox);

this.Controls.Add(myButton);

private void MyButton_Click(object sender, EventArgs e)

myLabel.Text = "Hello, " + myTextBox.Text + "!";

[STAThread]

public static void Main()

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.

LinkLabel Control ka Overview

- 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

myLinkLabel.Text = "Visit our website!";

```

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

myLinkLabel.Links.Add(0, 4); // 0 se start hoke 4 characters tak link hai

```

Common Events of LinkLabel

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);

private void MyLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

System.Diagnostics.Process.Start("https://www.example.com"); // Browser mein URL


open karega

}
```

Example: Using LinkLabel in Windows Forms

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 class MyForm : Form

private LinkLabel myLinkLabel;

public MyForm()

// LinkLabel create aur configure karte hain

myLinkLabel = new LinkLabel();

myLinkLabel.Text = "Click here to visit Google";

myLinkLabel.Location = new Point(20, 20);

myLinkLabel.AutoSize = true;

myLinkLabel.LinkColor = Color.Blue;

myLinkLabel.VisitedLinkColor = Color.Purple;
// LinkClicked event handle karte hain

myLinkLabel.LinkClicked += new
LinkLabelLinkClickedEventHandler(MyLinkLabel_LinkClicked);

// Form mein LinkLabel add karte hain

this.Controls.Add(myLinkLabel);

private void MyLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

// Link click hone par browser mein URL open karega

System.Diagnostics.Process.Start("https://www.google.com");

[STAThread]

public static void Main()

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.

Button Control ka Overview

- 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:

- Button ke upar display hone wala text set karta hai.

- Example:

```csharp

myButton.Text = "Submit";

```

2. Font:

- Button ke text ka font set karta hai.

- Example:

```csharp

myButton.Font = new Font("Arial", 10, FontStyle.Bold);

```

3. BackColor:

- Button ka background color set karta hai.

- Example:

```csharp

myButton.BackColor = Color.LightBlue;

```

4. ForeColor:

- Button text ka color set karta hai.


- Example:

```csharp

myButton.ForeColor = Color.White;

```

5. Enabled:

- Button ko enable ya disable karta hai. Agar `false` ho toh button click nahi hoga.

- Example:

```csharp

myButton.Enabled = false; // Button ko disable kar diya

```

6. FlatStyle:

- Button ke appearance ko set karta hai (`Standard`, `Flat`, `Popup`, `System`).

- Example:

```csharp

myButton.FlatStyle = FlatStyle.Flat;

```

7. Image:

- Button par image set karne ke liye use hota hai.

- Example:

```csharp

myButton.Image = Image.FromFile("path/to/image.png");

```
Common Methods of Button

1. PerformClick():

- Programmatically button click event ko trigger karta hai.

- Example:

```csharp

myButton.PerformClick(); // Button ko click simulate karega

```

Common Events of Button

1. Click:

- Jab user button par click karega, toh yeh event trigger hota hai.

- Example:

```csharp

myButton.Click += new EventHandler(MyButton_Click);

private void MyButton_Click(object sender, EventArgs e)

MessageBox.Show("Button Clicked!");

```

2. MouseEnter and MouseLeave:

- 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

myButton.MouseEnter += (s, e) => myButton.BackColor = Color.LightGreen; // Mouse


aane par background green ho jayega

myButton.MouseLeave += (s, e) => myButton.BackColor = Color.LightBlue; // Mouse


jaane par light blue ho jayega

```

Example: Using Button in Windows Forms

Yeh ek example hai jisme hum ek Button ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private Button myButton;

private Label myLabel;

public MyForm()

// Button create aur configure karte hain

myButton = new Button();


myButton.Text = "Click Me!";

myButton.Location = new Point(50, 50);

myButton.Size = new Size(100, 30);

myButton.Click += new EventHandler(MyButton_Click);

// Label create karte hain taaki button click hone par message dikhaye

myLabel = new Label();

myLabel.Text = "Welcome to My App!";

myLabel.Location = new Point(50, 100);

myLabel.AutoSize = true;

// Form mein Button aur Label add karte hain

this.Controls.Add(myButton);

this.Controls.Add(myLabel);

private void MyButton_Click(object sender, EventArgs e)

myLabel.Text = "Button clicked!";

[STAThread]

public static void Main()

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.

CheckBox Control ka Overview


- Namespace: `System.Windows.Forms`

- 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.

Common Properties of CheckBox

1. Text:

- CheckBox ke saath display hone wala text set karta hai.

- Example:

```csharp

myCheckBox.Text = "Accept Terms and Conditions";

```

2. Checked:

- Yeh property batati hai ki CheckBox checked hai ya nahi (true ya false).

- Example:

```csharp

bool isChecked = myCheckBox.Checked;

myCheckBox.Checked = true; // CheckBox ko checked set kar diya

```

3. CheckState:

- CheckBox ki state represent karta hai - `Checked`, `Unchecked`, ya `Indeterminate`.


- Example:

```csharp

myCheckBox.CheckState = CheckState.Indeterminate; // Half-selected state

```

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;

```

Common Methods of CheckBox

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

myCheckBox.PerformClick(); // CheckBox ko click simulate karta hai

```

Common Events of CheckBox

1. CheckedChanged:

- Jab CheckBox ki checked state change ho jaye, toh yeh event trigger hota hai.

- Example:

```csharp

myCheckBox.CheckedChanged += new EventHandler(MyCheckBox_CheckedChanged);

private void MyCheckBox_CheckedChanged(object sender, EventArgs e)

if (myCheckBox.Checked)

Console.WriteLine("CheckBox checked hai!");

else

Console.WriteLine("CheckBox unchecked hai!");

```
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);

private void MyCheckBox_CheckStateChanged(object sender, EventArgs e)

Console.WriteLine("CheckBox ki state change ho gayi!");

```

Example: Using CheckBox in Windows Forms

Yeh ek example hai jisme hum CheckBox ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

{
private CheckBox myCheckBox;

private Label myLabel;

public MyForm()

// CheckBox create aur configure karte hain

myCheckBox = new CheckBox();

myCheckBox.Text = "Accept Terms and Conditions";

myCheckBox.Location = new Point(20, 20);

myCheckBox.CheckedChanged += new
EventHandler(MyCheckBox_CheckedChanged);

// Label create karte hain jo CheckBox ki state bataye

myLabel = new Label();

myLabel.Text = "Status: Not Accepted";

myLabel.Location = new Point(20, 50);

myLabel.AutoSize = true;

// Form mein CheckBox aur Label add karte hain

this.Controls.Add(myCheckBox);

this.Controls.Add(myLabel);

private void MyCheckBox_CheckedChanged(object sender, EventArgs e)

if (myCheckBox.Checked)
{

myLabel.Text = "Status: Accepted";

else

myLabel.Text = "Status: Not Accepted";

[STAThread]

public static void Main()

Application.EnableVisualStyles();

Application.Run(new MyForm());

```

Is example mein:

- CheckBox ka text "Accept Terms and Conditions" hai.

- 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.

RadioButton Control ka Overview

- 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.

Common Properties of RadioButton

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

bool isSelected = myRadioButton.Checked;

myRadioButton.Checked = true; // RadioButton ko select kar diya

```

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:

- RadioButton ki appearance ko define karta hai (`Normal` ya `Button`).

- 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);

private void MyRadioButton_CheckedChanged(object sender, EventArgs e)

if (myRadioButton.Checked)

Console.WriteLine("RadioButton selected hai!");

else

Console.WriteLine("RadioButton deselected hai!");

```

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

GroupBox myGroupBox = new GroupBox();

myGroupBox.Text = "Select Gender";

myGroupBox.Size = new Size(200, 100);

myGroupBox.Location = new Point(20, 20);

RadioButton maleRadioButton = new RadioButton();

maleRadioButton.Text = "Male";

maleRadioButton.Location = new Point(10, 20);

RadioButton femaleRadioButton = new RadioButton();

femaleRadioButton.Text = "Female";

femaleRadioButton.Location = new Point(10, 50);

myGroupBox.Controls.Add(maleRadioButton);

myGroupBox.Controls.Add(femaleRadioButton);

this.Controls.Add(myGroupBox);

```

Common Events of RadioButton


1. CheckedChanged:

- 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

myRadioButton.Click += (s, e) => Console.WriteLine("RadioButton clicked!");

```

Example: Using RadioButton in Windows Forms

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

private RadioButton maleRadioButton;

private RadioButton femaleRadioButton;

private Label myLabel;

public MyForm()

// GroupBox create karte hain

GroupBox genderGroupBox = new GroupBox();

genderGroupBox.Text = "Select Gender";

genderGroupBox.Location = new Point(20, 20);

genderGroupBox.Size = new Size(200, 100);

// RadioButton for Male create karte hain

maleRadioButton = new RadioButton();

maleRadioButton.Text = "Male";

maleRadioButton.Location = new Point(10, 20);

maleRadioButton.CheckedChanged += new
EventHandler(RadioButton_CheckedChanged);

// RadioButton for Female create karte hain

femaleRadioButton = new RadioButton();

femaleRadioButton.Text = "Female";

femaleRadioButton.Location = new Point(10, 50);


femaleRadioButton.CheckedChanged += new
EventHandler(RadioButton_CheckedChanged);

// GroupBox mein RadioButtons add karte hain

genderGroupBox.Controls.Add(maleRadioButton);

genderGroupBox.Controls.Add(femaleRadioButton);

// Label create karte hain jo selection show kare

myLabel = new Label();

myLabel.Text = "Gender: Not Selected";

myLabel.Location = new Point(20, 150);

myLabel.AutoSize = true;

// Form mein GroupBox aur Label add karte hain

this.Controls.Add(genderGroupBox);

this.Controls.Add(myLabel);

private void RadioButton_CheckedChanged(object sender, EventArgs e)

if (maleRadioButton.Checked)

myLabel.Text = "Gender: Male";

else if (femaleRadioButton.Checked)

{
myLabel.Text = "Gender: Female";

[STAThread]

public static void Main()

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.

Panel Control ka Overview

- 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.

Common Properties of Panel

1. BackColor:

- Panel ka background color set karta hai.

- 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

myPanel.BorderStyle = BorderStyle.FixedSingle; // Panel ka border ek single line ka ho


jayega

```

3. Size:

- Panel ki width aur height set karta hai.

- Example:

```csharp

myPanel.Size = new Size(200, 150); // Width 200 aur height 150 set karta hai

```

4. Location:

- Panel ki position set karta hai (parent control ke hisaab se).

- 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

myPanel.Controls.Add(myButton); // Panel mein ek button add karta hai

```

Common Methods of Panel

1. Controls.Add():

- Panel mein child controls add karne ke liye use hota hai.

- Example:

```csharp

myPanel.Controls.Add(myLabel); // Panel mein label add karta hai

```

2. Clear():
- Panel ke andar saare child controls ko remove karta hai.

- Example:

```csharp

myPanel.Controls.Clear(); // Panel ke saare controls remove ho jayenge

```

Example: Using Panel in Windows Forms

Yahan ek example hai jisme hum Panel ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private Panel myPanel;

private Button button1, button2;

private Label myLabel;

public MyForm()

// Panel create aur configure karte hain

myPanel = new Panel();

myPanel.Size = new Size(200, 200);


myPanel.Location = new Point(20, 20);

myPanel.BorderStyle = BorderStyle.FixedSingle;

// Buttons create karte hain

button1 = new Button();

button1.Text = "Button 1";

button1.Location = new Point(10, 10);

button2 = new Button();

button2.Text = "Button 2";

button2.Location = new Point(10, 50);

// Label create karte hain

myLabel = new Label();

myLabel.Text = "Panel Example";

myLabel.Location = new Point(10, 90);

myLabel.AutoSize = true;

// Panel mein Buttons aur Label add karte hain

myPanel.Controls.Add(button1);

myPanel.Controls.Add(button2);

myPanel.Controls.Add(myLabel);

// Form mein Panel add karte hain

this.Controls.Add(myPanel);

}
[STAThread]

public static void Main()

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.

Use Cases of Panel Control

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.

GroupBox Control ka Overview

- 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.

Common Properties of GroupBox

1. Text:

- Yeh property GroupBox ka title set karti hai, jo group ka naam ya context define karta
hai.

- Example:

```csharp

myGroupBox.Text = "Select Payment Method"; // Title "Select Payment Method" set


karega

```

2. Font:

- Yeh GroupBox ke title ka font set karta hai.

- Example:

```csharp

myGroupBox.Font = new Font("Arial", 10, FontStyle.Bold); // Title ka font Arial aur bold
ho jayega

```

3. Size:

- Yeh GroupBox ki width aur height set karta hai.

- 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

myGroupBox.Location = new Point(20, 20); // GroupBox ki position (x=20, y=20) set


karega

```

5. Controls:

- Yeh property GroupBox mein child controls add karne ya manage karne ke liye use hoti
hai.

- Example:

```csharp

myGroupBox.Controls.Add(myRadioButton); // GroupBox mein ek radio button add karta


hai

```

Common Methods of GroupBox

1. Controls.Add():

- Yeh method child controls ko GroupBox mein add karne ke liye use hota hai.

- Example:
```csharp

myGroupBox.Controls.Add(myTextBox); // GroupBox mein text box add karta hai

```

2. Clear() (Controls collection ke through):

- Yeh GroupBox mein saare controls ko remove karta hai.

- Example:

```csharp

myGroupBox.Controls.Clear(); // GroupBox ke saare controls remove kar deta hai

```

Example: Using GroupBox in Windows Forms

Yahan ek example hai jisme hum GroupBox ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private GroupBox myGroupBox;

private RadioButton radioButton1, radioButton2;

public MyForm()
{

// GroupBox create aur configure karte hain

myGroupBox = new GroupBox();

myGroupBox.Text = "Select Gender";

myGroupBox.Size = new Size(200, 100);

myGroupBox.Location = new Point(20, 20);

// RadioButtons create karte hain

radioButton1 = new RadioButton();

radioButton1.Text = "Male";

radioButton1.Location = new Point(10, 20);

radioButton2 = new RadioButton();

radioButton2.Text = "Female";

radioButton2.Location = new Point(10, 50);

// GroupBox mein RadioButtons add karte hain

myGroupBox.Controls.Add(radioButton1);

myGroupBox.Controls.Add(radioButton2);

// Form mein GroupBox add karte hain

this.Controls.Add(myGroupBox);

[STAThread]

public static void Main()


{

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.

Use Cases of GroupBox Control

1. Logically Grouping Related Controls:

- Jab aapko form mein related options ko logically group karna ho, toh GroupBox useful
hota hai. Jaise radio buttons, checkboxes, ya settings ke controls.

2. Improving User Experience:

- 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.

GroupBox Windows Forms applications mein UI ko organized aur user-friendly banane


mein kaafi useful hota hai. Yeh ek acha tarika hai visually related controls ko ek saath
group karne ka aur unhe ek proper title dene ka, jisse user experience aur bhi improve ho
jata 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.

ListBox Control ka Overview

- 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

myListBox.Items.Add("Apple"); // Ek item add karta hai

myListBox.Items.AddRange(new string[] { "Banana", "Cherry", "Grapes" }); // Multiple


items add karta hai

```

2. SelectedItem:

- Yeh property current selected item ko represent karti hai.

- Example:

```csharp

var selectedItem = myListBox.SelectedItem; // Select kiya hua item get karta hai

```

3. SelectedIndex:

- Yeh property selected item ka index (position) return karti hai.

- 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:

- `SelectionMode.One` (default) - Sirf ek item select kar sakte hain.

- `SelectionMode.MultiSimple` - Multiple items ko bina `Ctrl` ya `Shift` press kare


select kar sakte hain.

- `SelectionMode.MultiExtended` - Multiple items ko `Ctrl` ya `Shift` ke saath select


kar sakte hain.

- Example:

```csharp

myListBox.SelectionMode = SelectionMode.MultiExtended; // Multiple items select kar


sakte hain

```

5. Sorted:

- Agar `true` set ho, toh ListBox ke items automatically sorted order mein dikhaye jaate
hain.

- Example:

```csharp

myListBox.Sorted = true;

```

Common Methods of ListBox

1. Items.Add():

- Ek item ListBox mein add karta hai.

- Example:

```csharp
myListBox.Items.Add("Orange");

```

2. Items.Remove():

- Yeh method specific item ko remove karta hai.

- Example:

```csharp

myListBox.Items.Remove("Banana"); // "Banana" ko remove karta hai

```

3. Items.RemoveAt():

- Yeh method specified index par item ko remove karta hai.

- Example:

```csharp

myListBox.Items.RemoveAt(1); // Index 1 par item ko remove karta hai

```

4. Items.Clear():

- Saare items ko ListBox se remove karta hai.

- Example:

```csharp

myListBox.Items.Clear(); // ListBox ke saare items remove ho jayenge

```

Common Events of ListBox


1. SelectedIndexChanged:

- Jab user kisi naya item ko select karta hai toh yeh event trigger hota hai.

- Example:

```csharp

myListBox.SelectedIndexChanged += new
EventHandler(MyListBox_SelectedIndexChanged);

private void MyListBox_SelectedIndexChanged(object sender, EventArgs e)

if (myListBox.SelectedItem != null)

MessageBox.Show("Selected Item: " + myListBox.SelectedItem.ToString());

```

Example: Using ListBox in Windows Forms

Yahan ek example hai jisme hum ListBox ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form


{

private ListBox myListBox;

private Label myLabel;

public MyForm()

// ListBox create aur configure karte hain

myListBox = new ListBox();

myListBox.Location = new Point(20, 20);

myListBox.Size = new Size(150, 100);

myListBox.SelectionMode = SelectionMode.One;

// ListBox mein items add karte hain

myListBox.Items.Add("Apple");

myListBox.Items.Add("Banana");

myListBox.Items.Add("Cherry");

myListBox.Items.Add("Grapes");

// SelectedIndexChanged event handle karte hain

myListBox.SelectedIndexChanged += new
EventHandler(MyListBox_SelectedIndexChanged);

// Label create karte hain jo selected item show kare

myLabel = new Label();

myLabel.Text = "Selected Item: None";

myLabel.Location = new Point(20, 130);


myLabel.AutoSize = true;

// Form mein ListBox aur Label add karte hain

this.Controls.Add(myListBox);

this.Controls.Add(myLabel);

private void MyListBox_SelectedIndexChanged(object sender, EventArgs e)

if (myListBox.SelectedItem != null)

myLabel.Text = "Selected Item: " + myListBox.SelectedItem.ToString();

[STAThread]

public static void Main()

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.

Use Cases of ListBox Control

1. Displaying a List of Options:

- 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.

CheckedListBox Control ka Overview

- 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.

Common Properties of CheckedListBox

1. Items:

- CheckedListBox mein items add ya manage karne ke liye use hoti hai.

- Example:

```csharp

myCheckedListBox.Items.Add("Option 1");

myCheckedListBox.Items.AddRange(new string[] { "Option 2", "Option 3", "Option 4" });

```

2. CheckedItems:

- Yeh property CheckedListBox ke andar currently checked items ko return karti hai.
- Example:

```csharp

foreach (var item in myCheckedListBox.CheckedItems)

Console.WriteLine(item.ToString()); // Saare checked items ko print karta hai

```

3. CheckedIndices:

- Yeh property checked items ke indices ko return karti hai.

- Example:

```csharp

foreach (int index in myCheckedListBox.CheckedIndices)

Console.WriteLine("Checked index: " + index); // Saare checked items ke index ko print


karta hai

```

4. CheckOnClick:

- Agar `true` set ho, toh user ek baar item par click karke usko check/uncheck kar sakta
hai.

- Example:

```csharp

myCheckedListBox.CheckOnClick = true; // Click karte hi item check/uncheck ho jayega

```
Common Methods of CheckedListBox

1. SetItemChecked():

- Yeh method specific item ko checked ya unchecked set karta hai, index ke hisaab se.

- Example:

```csharp

myCheckedListBox.SetItemChecked(1, true); // Index 1 par item ko checked set karta


hai

```

2. SetItemCheckState():

- Yeh method specific item ki state set karta hai (`Checked`, `Unchecked`, ya
`Indeterminate`).

- Example:

```csharp

myCheckedListBox.SetItemCheckState(0, CheckState.Indeterminate); // Item ko half-


checked set karta hai

```

Common Events of CheckedListBox

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);

private void MyCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)

string item = myCheckedListBox.Items[e.Index].ToString();

if (e.NewValue == CheckState.Checked)

Console.WriteLine(item + " checked!");

else

Console.WriteLine(item + " unchecked!");

```

Example: Using CheckedListBox in Windows Forms

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

private CheckedListBox myCheckedListBox;

private Button myButton;

private Label myLabel;

public MyForm()

// CheckedListBox create aur configure karte hain

myCheckedListBox = new CheckedListBox();

myCheckedListBox.Location = new Point(20, 20);

myCheckedListBox.Size = new Size(200, 100);

myCheckedListBox.CheckOnClick = true;

// CheckedListBox mein items add karte hain

myCheckedListBox.Items.Add("Apple");

myCheckedListBox.Items.Add("Banana");

myCheckedListBox.Items.Add("Cherry");

myCheckedListBox.Items.Add("Grapes");

// Button create karte hain

myButton = new Button();

myButton.Text = "Show Checked Items";

myButton.Location = new Point(20, 130);

myButton.Click += new EventHandler(MyButton_Click);


// Label create karte hain jo selected items show kare

myLabel = new Label();

myLabel.Text = "Selected Items: None";

myLabel.Location = new Point(20, 170);

myLabel.AutoSize = true;

// Form mein CheckedListBox, Button, aur Label add karte hain

this.Controls.Add(myCheckedListBox);

this.Controls.Add(myButton);

this.Controls.Add(myLabel);

private void MyButton_Click(object sender, EventArgs e)

string selectedItems = "Selected Items: ";

foreach (var item in myCheckedListBox.CheckedItems)

selectedItems += item.ToString() + ", ";

myLabel.Text = selectedItems.TrimEnd(',', ' ');

[STAThread]

public static void Main()

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.

Use Cases of CheckedListBox Control

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.

ComboBox Control ka Overview

- 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.

Common Properties of ComboBox

1. Items:
- ComboBox mein options add ya manage karne ke liye use hoti hai.

- Example:

```csharp

myComboBox.Items.Add("Option 1");

myComboBox.Items.AddRange(new string[] { "Option 2", "Option 3", "Option 4" });

```

2. Text:

- Yeh property currently selected value ya typed value ko represent karti hai.

- Example:

```csharp

myComboBox.Text = "Please select an option"; // Default message ya selected value set


karta hai

```

3. SelectedItem:

- Yeh property current selected item ko represent karti hai.

- 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).

- `ComboBoxStyle.Simple` - Drop-down nahi, saari items visible hoti hain.

- Example:

```csharp

myComboBox.DropDownStyle = ComboBoxStyle.DropDownList; // User sirf drop-down


se select kar sakta hai

```

6. MaxDropDownItems:

- Yeh property specify karti hai ki drop-down list mein maximum kitne items dikhaye
jayenge (scrolling ke liye).

- Example:

```csharp

myComboBox.MaxDropDownItems = 5; // Max 5 items ek baar mein dikhaye jayenge

```

Common Methods of ComboBox


1. Items.Add():

- Ek item ComboBox mein add karta hai.

- Example:

```csharp

myComboBox.Items.Add("Orange");

```

2. Items.Remove():

- Specific item ko ComboBox se remove karta hai.

- Example:

```csharp

myComboBox.Items.Remove("Option 2");

```

3. Items.Clear():

- Saare items ko ComboBox se remove karta hai.

- Example:

```csharp

myComboBox.Items.Clear();

```

Common Events of ComboBox

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);

private void MyComboBox_SelectedIndexChanged(object sender, EventArgs e)

if (myComboBox.SelectedItem != null)

MessageBox.Show("Selected Item: " + myComboBox.SelectedItem.ToString());

```

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

myComboBox.TextChanged += (s, e) => Console.WriteLine("Text Changed: " +


myComboBox.Text);

```

Example: Using ComboBox in Windows Forms

Yahan ek example hai jisme hum ComboBox ka use kar rahe hain:

```csharp
using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private ComboBox myComboBox;

private Label myLabel;

public MyForm()

// ComboBox create aur configure karte hain

myComboBox = new ComboBox();

myComboBox.Location = new Point(20, 20);

myComboBox.Size = new Size(150, 20);

myComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

// ComboBox mein items add karte hain

myComboBox.Items.Add("Apple");

myComboBox.Items.Add("Banana");

myComboBox.Items.Add("Cherry");

myComboBox.Items.Add("Grapes");

// SelectedIndexChanged event handle karte hain

myComboBox.SelectedIndexChanged += new
EventHandler(MyComboBox_SelectedIndexChanged);
// Label create karte hain jo selected item show kare

myLabel = new Label();

myLabel.Text = "Selected Item: None";

myLabel.Location = new Point(20, 60);

myLabel.AutoSize = true;

// Form mein ComboBox aur Label add karte hain

this.Controls.Add(myComboBox);

this.Controls.Add(myLabel);

private void MyComboBox_SelectedIndexChanged(object sender, EventArgs e)

if (myComboBox.SelectedItem != null)

myLabel.Text = "Selected Item: " + myComboBox.SelectedItem.ToString();

[STAThread]

public static void Main()

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.

Use Cases of ComboBox Control

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.

3. Settings and Preferences:

- 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.

PictureBox Control ka Overview

- 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.

Common Properties of PictureBox

1. Image:

- PictureBox mein display hone wali image ko set ya get karta hai.

- Example:

```csharp

myPictureBox.Image = Image.FromFile("path/to/image.jpg"); // Local file se image load


karta hai

```
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

myPictureBox.ImageLocation = "https://example.com/image.jpg"; // URL se image load


karta hai

```

3. SizeMode:

- Yeh property define karti hai ki PictureBox mein image kaise fit hogi. Options hain:

- `Normal` - Image original size mein show hogi.

- `StretchImage` - Image ko PictureBox ke size ke hisaab se stretch karta hai.

- `AutoSize` - PictureBox ki size ko image ki size ke hisaab se adjust karta hai.

- `CenterImage` - Image ko PictureBox ke center mein show karta hai.

- `Zoom` - Image ko PictureBox ke andar zoom karta hai bina aspect ratio ko lose kiye.

- Example:

```csharp

myPictureBox.SizeMode = PictureBoxSizeMode.StretchImage; // Image ko stretch karta


hai taaki poori PictureBox fill ho jaye

```

4. BorderStyle:

- PictureBox ke border ka style set karta hai. Options hain `None`, `FixedSingle`, aur
`Fixed3D`.

- Example:
```csharp

myPictureBox.BorderStyle = BorderStyle.Fixed3D; // 3D border add karta hai

```

Common Methods of PictureBox

1. Load():

- Image ko specified path ya URL se load karta hai.

- Example:

```csharp

myPictureBox.Load("https://example.com/image.jpg"); // URL se image load karta hai

```

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

myPictureBox.LoadAsync("https://example.com/image.jpg"); // Asynchronously image


load karta hai

```

Example: Using PictureBox in Windows Forms

Yahan ek example hai jisme hum PictureBox ka use kar rahe hain:
```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private PictureBox myPictureBox;

private Button loadImageButton;

public MyForm()

// PictureBox create aur configure karte hain

myPictureBox = new PictureBox();

myPictureBox.Size = new Size(200, 150);

myPictureBox.Location = new Point(20, 20);

myPictureBox.BorderStyle = BorderStyle.FixedSingle;

myPictureBox.SizeMode = PictureBoxSizeMode.StretchImage;

// Button create karte hain image load karne ke liye

loadImageButton = new Button();

loadImageButton.Text = "Load Image";

loadImageButton.Location = new Point(20, 200);

loadImageButton.Click += new EventHandler(LoadImageButton_Click);

// Form mein PictureBox aur Button add karte hain


this.Controls.Add(myPictureBox);

this.Controls.Add(loadImageButton);

private void LoadImageButton_Click(object sender, EventArgs e)

// Image load karte hain PictureBox mein

myPictureBox.Image = Image.FromFile("path/to/your/image.jpg");

[STAThread]

public static void Main()

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.

Use Cases of PictureBox Control

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.

4. Product or Item Visualization:

- 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.

- Load() aur LoadAsync() methods ka use image ko synchronously ya asynchronously load


karne ke liye 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:

1. HScrollBar (Horizontal Scroll Bar)

2. VScrollBar (Vertical Scroll Bar)

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.

ScrollBar Control ka Overview

- 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.

Types of Scroll Bars

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.

Common Properties of ScrollBar


1. Minimum:

- Scroll bar ka minimum value set karta hai, jisse scroll bar shuru hota hai.

- Example:

```csharp

myScrollBar.Minimum = 0; // Minimum value 0 set karta hai

```

2. Maximum:

- Scroll bar ka maximum value set karta hai, jisse scroll bar khatam hota hai.

- Example:

```csharp

myScrollBar.Maximum = 100; // Maximum value 100 set karta hai

```

3. Value:

- Scroll bar ki current position ko represent karta hai.

- Example:

```csharp

int currentValue = myScrollBar.Value; // Current position get karta hai

```

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

myScrollBar.SmallChange = 1; // Thumb ek baar mein 1 unit move karega

```

Common Methods of ScrollBar

Scroll bars ke methods limited hain kyunki scroll bars mainly user interactions handle
karte hain. Lekin kuch common methods hain:

1. PerformScroll():

- Programmatically scroll bar ko move karne ke liye use hota hai.

Common Events of ScrollBar

1. Scroll:

- Jab user scroll bar ko move karta hai toh yeh event trigger hota hai.

- Example:

```csharp

myScrollBar.Scroll += new ScrollEventHandler(MyScrollBar_Scroll);


private void MyScrollBar_Scroll(object sender, ScrollEventArgs e)

Console.WriteLine("Scroll value: " + e.NewValue); // Scroll ki current value print karta


hai

```

2. ValueChanged:

- Jab scroll bar ki value change ho jaye toh yeh event trigger hota hai.

- Example:

```csharp

myScrollBar.ValueChanged += (s, e) => Console.WriteLine("New Scroll Value: " +


myScrollBar.Value);

```

Example: Using HScrollBar and VScrollBar in Windows Forms

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 class MyForm : Form


{

private HScrollBar hScrollBar;

private VScrollBar vScrollBar;

private Label myLabel;

public MyForm()

// Horizontal ScrollBar create aur configure karte hain

hScrollBar = new HScrollBar();

hScrollBar.Location = new Point(20, 20);

hScrollBar.Width = 200;

hScrollBar.Minimum = 0;

hScrollBar.Maximum = 100;

hScrollBar.ValueChanged += new EventHandler(HScrollBar_ValueChanged);

// Vertical ScrollBar create aur configure karte hain

vScrollBar = new VScrollBar();

vScrollBar.Location = new Point(250, 20);

vScrollBar.Height = 150;

vScrollBar.Minimum = 0;

vScrollBar.Maximum = 100;

vScrollBar.ValueChanged += new EventHandler(VScrollBar_ValueChanged);

// Label create karte hain jo scroll values show kare

myLabel = new Label();

myLabel.Text = "Scroll Values: H=0, V=0";


myLabel.Location = new Point(20, 200);

myLabel.AutoSize = true;

// Form mein ScrollBars aur Label add karte hain

this.Controls.Add(hScrollBar);

this.Controls.Add(vScrollBar);

this.Controls.Add(myLabel);

private void HScrollBar_ValueChanged(object sender, EventArgs e)

myLabel.Text = $"Scroll Values: H={hScrollBar.Value}, V={vScrollBar.Value}";

private void VScrollBar_ValueChanged(object sender, EventArgs e)

myLabel.Text = $"Scroll Values: H={hScrollBar.Value}, V={vScrollBar.Value}";

[STAThread]

public static void Main()

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.

Use Cases of Scroll Bars

1. Scrolling Large Content:

- 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.

2. Forms with Dynamic Controls:

- 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.

3. Image Zooming and Panning:

- 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.

Splitter Control ka Overview

- 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.

How Splitter Works

- 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

mySplitter.Dock = DockStyle.Left; // Splitter ko left side mein dock karta hai

```

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

mySplitter.MinExtra = 100; // Minimum size 100 pixels

```

3. MinSize:

- Yeh property Splitter ke left ya top panel ke minimum size ko specify karti hai.

- Example:

```csharp

mySplitter.MinSize = 50; // Minimum size 50 pixels

```

Example: Using Splitter in Windows Forms


Yahan ek example hai jisme hum Splitter ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private Panel leftPanel, rightPanel;

private Splitter mySplitter;

public MyForm()

// Left Panel create aur configure karte hain

leftPanel = new Panel();

leftPanel.BackColor = Color.LightBlue;

leftPanel.Dock = DockStyle.Left;

leftPanel.Width = 150;

// Right Panel create aur configure karte hain

rightPanel = new Panel();

rightPanel.BackColor = Color.LightGreen;

rightPanel.Dock = DockStyle.Fill;
// Splitter create aur configure karte hain

mySplitter = new Splitter();

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

// Form mein Panels aur Splitter add karte hain

this.Controls.Add(rightPanel);

this.Controls.Add(mySplitter);

this.Controls.Add(leftPanel);

[STAThread]

public static void Main()

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.

Use Cases of Splitter Control

1. Resizable Panels in Dashboards:

- 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.

2. File Explorer Layout:

- 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.

TrackBar Control ka Overview

- 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.

Common Properties of TrackBar

1. Minimum:

- TrackBar ka minimum value set karta hai, jahan se slider shuru hota hai.

- Example:

```csharp

myTrackBar.Minimum = 0; // Minimum value 0 set karta hai

```

2. Maximum:
- TrackBar ka maximum value set karta hai, jahan tak slider move kar sakta hai.

- Example:

```csharp

myTrackBar.Maximum = 100; // Maximum value 100 set karta hai

```

3. Value:

- TrackBar ki current value ko represent karta hai, jo slider ki current position hai.

- Example:

```csharp

myTrackBar.Value = 50; // Default value 50 set karta hai

```

4. TickFrequency:

- Yeh property specify karti hai ki ticks (lines) har kitne intervals par honge.

- Example:

```csharp

myTrackBar.TickFrequency = 10; // Har 10 units par ek tick mark hoga

```

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

myTrackBar.SmallChange = 1; // Arrow key se 1 unit change hoga


```

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

myTrackBar.LargeChange = 5; // Page up ya down se 5 units change hogi

```

7. Orientation:

- Yeh property TrackBar ki orientation ko define karti hai: `Horizontal` ya `Vertical`.

- Example:

```csharp

myTrackBar.Orientation = Orientation.Horizontal; // TrackBar horizontal orientation mein


dikhai dega

```

Common Methods of TrackBar

1. PerformStep():

- TrackBar ki value ko programmatically ek step aage ya peeche le jaane ke liye use hota
hai.

Common Events of TrackBar

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

myTrackBar.Scroll += new EventHandler(MyTrackBar_Scroll);

private void MyTrackBar_Scroll(object sender, EventArgs e)

Console.WriteLine("Current Value: " + myTrackBar.Value); // Current value print karta


hai

```

2. ValueChanged:

- Jab TrackBar ki value change hoti hai (chahe user kare ya programmatically), tab yeh
event trigger hota hai.

- Example:

```csharp

myTrackBar.ValueChanged += (s, e) => Console.WriteLine("Value Changed to: " +


myTrackBar.Value);

```

Example: Using TrackBar in Windows Forms

Yahan ek example hai jisme hum TrackBar ka use kar rahe hain:

```csharp
using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private TrackBar myTrackBar;

private Label myLabel;

public MyForm()

// TrackBar create aur configure karte hain

myTrackBar = new TrackBar();

myTrackBar.Location = new Point(20, 20);

myTrackBar.Minimum = 0;

myTrackBar.Maximum = 100;

myTrackBar.Value = 50;

myTrackBar.TickFrequency = 10;

myTrackBar.Orientation = Orientation.Horizontal;

myTrackBar.Scroll += new EventHandler(MyTrackBar_Scroll);

// Label create karte hain jo current value show kare

myLabel = new Label();

myLabel.Text = "Current Value: " + myTrackBar.Value;

myLabel.Location = new Point(20, 70);

myLabel.AutoSize = true;
// Form mein TrackBar aur Label add karte hain

this.Controls.Add(myTrackBar);

this.Controls.Add(myLabel);

private void MyTrackBar_Scroll(object sender, EventArgs e)

myLabel.Text = "Current Value: " + myTrackBar.Value;

[STAThread]

public static void Main()

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.

Use Cases of TrackBar Control


1. Volume Control:

- 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.

3. Progress or Speed Setting:

- 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.

- Minimum, Maximum, Value, TickFrequency, aur Orientation properties TrackBar ke


behavior ko control karne mein help karti hain.

- Scroll aur ValueChanged events ka use user ke interactions ke hisaab se real-time


updates dene ke liye hota 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:

1. DateTimePicker - User ko date ya time select karne ka option dene ke liye.

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.

# Common Properties of DateTimePicker

1. Value:

- Yeh property currently selected date ko represent karti hai.

- Example:

```csharp

DateTime selectedDate = myDateTimePicker.Value; // Current selected date get karta


hai

```

2. Format:

- Yeh property date aur time ka format set karti hai (`Long`, `Short`, `Time`, ya
`Custom`).
- Example:

```csharp

myDateTimePicker.Format = DateTimePickerFormat.Short; // Date ko short format mein


dikhata hai (dd/MM/yyyy)

```

3. MinDate and MaxDate:

- Minimum aur maximum date set karta hai jo user select kar sakta hai.

- Example:

```csharp

myDateTimePicker.MinDate = new DateTime(2023, 1, 1); // Minimum date 1st January


2023 set karta hai

myDateTimePicker.MaxDate = DateTime.Today; // Maximum date aaj ki date set karta


hai

```

# Common Events of DateTimePicker

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);

private void MyDateTimePicker_ValueChanged(object sender, EventArgs e)

{
MessageBox.Show("Selected Date: " + myDateTimePicker.Value.ToShortDateString());

```

# Example: Using DateTimePicker in Windows Forms

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private DateTimePicker myDateTimePicker;

private Label myLabel;

public MyForm()

// DateTimePicker create aur configure karte hain

myDateTimePicker = new DateTimePicker();

myDateTimePicker.Location = new Point(20, 20);

myDateTimePicker.Format = DateTimePickerFormat.Short;

myDateTimePicker.ValueChanged += new
EventHandler(MyDateTimePicker_ValueChanged);

// Label create karte hain jo selected date show kare


myLabel = new Label();

myLabel.Text = "Selected Date: " + myDateTimePicker.Value.ToShortDateString();

myLabel.Location = new Point(20, 60);

myLabel.AutoSize = true;

// Form mein DateTimePicker aur Label add karte hain

this.Controls.Add(myDateTimePicker);

this.Controls.Add(myLabel);

private void MyDateTimePicker_ValueChanged(object sender, EventArgs e)

myLabel.Text = "Selected Date: " + myDateTimePicker.Value.ToShortDateString();

[STAThread]

public static void Main()

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.

# Common Methods of ColorDialog

1. ShowDialog():

- ColorDialog ko display karta hai aur user se color select karwane ke liye use hota hai.

- Example:

```csharp

ColorDialog colorDialog = new ColorDialog();

if (colorDialog.ShowDialog() == DialogResult.OK)

this.BackColor = colorDialog.Color; // Selected color ko form ka background set karta


hai

```

Example: Using ColorDialog in Windows Forms

```csharp

private void ChangeColorButton_Click(object sender, EventArgs e)


{

ColorDialog colorDialog = new ColorDialog();

if (colorDialog.ShowDialog() == DialogResult.OK)

this.BackColor = colorDialog.Color; // Form ka background selected color se set hota


hai

```

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.

# Common Methods of FontDialog

1. ShowDialog():

- FontDialog ko display karta hai aur user se font select karwane ke liye use hota hai.

- Example:

```csharp

FontDialog fontDialog = new FontDialog();

if (fontDialog.ShowDialog() == DialogResult.OK)

myLabel.Font = fontDialog.Font; // Selected font ko label ke liye set karta hai

}
```

Example: Using FontDialog in Windows Forms

```csharp

private void ChangeFontButton_Click(object sender, EventArgs e)

FontDialog fontDialog = new FontDialog();

if (fontDialog.ShowDialog() == DialogResult.OK)

myLabel.Font = fontDialog.Font; // Label ka font user ke selected font se set hota hai

```

Summary

1. DateTimePicker:

- Date ya time select karne ke liye use hota hai.

- Useful properties: Value, Format, MinDate, MaxDate.

2. ColorDialog:

- User ko ek color select karne ke liye dialog box provide karta hai.

- Commonly used for selecting colors for form, controls, ya text.

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.

NotifyIcon Control ka Overview

- 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.

Common Properties of NotifyIcon

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

myNotifyIcon.Text = "My Application"; // Tooltip text set karta hai

```

3. Visible:

- NotifyIcon ko show ya hide karne ke liye use hoti hai.

- Example:

```csharp

myNotifyIcon.Visible = true; // NotifyIcon ko show karta hai

```

4. ContextMenuStrip:

- NotifyIcon ke saath ek context menu attach karta hai, jisse user ko right-click options
milte hain.

- Example:

```csharp

myNotifyIcon.ContextMenuStrip = myContextMenuStrip; // Context menu set karta hai

```

Common Methods of NotifyIcon


1. ShowBalloonTip():

- System tray mein ek balloon tip (tooltip notification) dikhata hai.

- Example:

```csharp

myNotifyIcon.ShowBalloonTip(3000, "Notification Title", "This is a test message.",


ToolTipIcon.Info);

```

Example: Using NotifyIcon in Windows Forms

Yahan ek example hai jisme hum NotifyIcon ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private NotifyIcon myNotifyIcon;

private ContextMenuStrip contextMenu;

public MyForm()

// Form properties set karte hain


this.Text = "NotifyIcon Example";

this.Size = new Size(400, 300);

// Context menu create karte hain jo NotifyIcon ke saath attach hoga

contextMenu = new ContextMenuStrip();

contextMenu.Items.Add("Open", null, Open_Click);

contextMenu.Items.Add("Exit", null, Exit_Click);

// NotifyIcon create aur configure karte hain

myNotifyIcon = new NotifyIcon();

myNotifyIcon.Icon = new Icon(SystemIcons.Application, 40, 40);

myNotifyIcon.Text = "My Application";

myNotifyIcon.ContextMenuStrip = contextMenu;

myNotifyIcon.Visible = true;

// Form minimize hone par balloon tip show karta hai

this.Resize += new EventHandler(MyForm_Resize);

private void MyForm_Resize(object sender, EventArgs e)

if (this.WindowState == FormWindowState.Minimized)

myNotifyIcon.ShowBalloonTip(3000, "Application Minimized", "The application is


minimized to tray.", ToolTipIcon.Info);

this.Hide(); // Minimize hone par form ko hide karta hai


}

private void Open_Click(object sender, EventArgs e)

this.Show(); // Form ko show karta hai

this.WindowState = FormWindowState.Normal; // Normal state mein laata hai

private void Exit_Click(object sender, EventArgs e)

myNotifyIcon.Visible = false; // NotifyIcon ko hide karta hai

Application.Exit(); // Application ko exit karta hai

[STAThread]

public static void Main()

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.

Use Cases of NotifyIcon Control

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.

2. Quick Actions via Context Menu:

- 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.

ToolTip Control ka Overview

- 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.

Common Properties of ToolTip

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

myToolTip.AutomaticDelay = 500; // 500 milliseconds delay set karta hai

```

2. AutoPopDelay:

- Yeh specify karta hai ki ToolTip kitne der tak visible rahega.

- Example:

```csharp

myToolTip.AutoPopDelay = 5000; // 5000 milliseconds (5 seconds) tak ToolTip visible


rahega

```

3. InitialDelay:

- Yeh specify karta hai ki ToolTip kitne time ke baad visible ho.

- Example:

```csharp

myToolTip.InitialDelay = 200; // 200 milliseconds ke baad ToolTip dikhna shuru hoga

```

4. ReshowDelay:

- Yeh specify karta hai ki ek ToolTip ke baad doosra ToolTip kitne delay ke baad dikhaya
jaaye.

- Example:

```csharp

myToolTip.ReshowDelay = 100; // 100 milliseconds ka delay hoga ek ToolTip ke baad


doosre mein
```

5. IsBalloon:

- Yeh property set karti hai ki ToolTip balloon style mein dikhaya jaye.

- Example:

```csharp

myToolTip.IsBalloon = true; // ToolTip balloon style mein show hoga

```

Common Methods of ToolTip

1. SetToolTip(Control, String):

- Yeh method specific control par ToolTip text set karne ke liye use hota hai.

- Example:

```csharp

myToolTip.SetToolTip(myButton, "Click here to submit the form"); // Button ke liye


ToolTip set karta hai

```

Example: Using ToolTip in Windows Forms

Yahan ek example hai jisme hum ToolTip ka use kar rahe hain:

```csharp

using System;

using System.Drawing;
using System.Windows.Forms;

public class MyForm : Form

private Button myButton;

private TextBox myTextBox;

private ToolTip myToolTip;

public MyForm()

// Button create aur configure karte hain

myButton = new Button();

myButton.Text = "Submit";

myButton.Location = new Point(20, 20);

// TextBox create aur configure karte hain

myTextBox = new TextBox();

myTextBox.Location = new Point(20, 60);

// ToolTip create aur configure karte hain

myToolTip = new ToolTip();

myToolTip.AutoPopDelay = 5000;

myToolTip.InitialDelay = 200;

myToolTip.ReshowDelay = 100;

myToolTip.IsBalloon = true; // Balloon style ToolTip set kar rahe hain


// Controls par ToolTips set karte hain

myToolTip.SetToolTip(myButton, "Click to submit the form data.");

myToolTip.SetToolTip(myTextBox, "Enter your name here.");

// Form mein Button aur TextBox add karte hain

this.Controls.Add(myButton);

this.Controls.Add(myTextBox);

[STAThread]

public static void Main()

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.

Use Cases of ToolTip Control


1. Guiding Users:

- 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.

- Common properties hain AutomaticDelay, AutoPopDelay, InitialDelay, ReshowDelay, aur


IsBalloon, jo ToolTip ke appearance aur behavior ko customize karne mein help karte hain.

- 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.

Timer Control ka Overview

- Namespace: `System.Windows.Forms` (for Windows Forms Timer)

- 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.

- Common Use Cases: Auto-refreshing data, periodic notifications, countdown timers,


automatic updates.

Common Properties of Timer

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:

- Yeh property specify karti hai ki Timer active hai ya nahi.

- Example:
```csharp

myTimer.Enabled = true; // Timer ko enable karta hai

```

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

```

Common Methods of Timer

1. Start():

- Timer ko start ya activate karne ke liye use hota hai.

- Example:

```csharp

myTimer.Start(); // Timer ko start karta hai

```

2. Stop():

- Timer ko stop ya deactivate karne ke liye use hota hai.

- Example:

```csharp

myTimer.Stop(); // Timer ko stop karta hai

```
Common Events of Timer

1. Tick:

- Jab Timer interval complete karta hai, toh yeh event trigger hota hai.

- Iska use repetitive actions perform karne ke liye hota hai.

- Example:

```csharp

myTimer.Tick += new EventHandler(MyTimer_Tick);

private void MyTimer_Tick(object sender, EventArgs e)

Console.WriteLine("Timer Tick Event Triggered");

```

Example: Using Timer in Windows Forms

Yahan ek example hai jisme hum Timer ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form


{

private Timer myTimer;

private Label myLabel;

private int counter;

public MyForm()

// Timer create aur configure karte hain

myTimer = new Timer();

myTimer.Interval = 1000; // Timer har 1 second par tick hoga

myTimer.Tick += new EventHandler(MyTimer_Tick);

// Label create karte hain jisme counter show hoga

myLabel = new Label();

myLabel.Text = "Counter: 0";

myLabel.Location = new Point(20, 20);

myLabel.AutoSize = true;

// Start Button create karte hain

Button startButton = new Button();

startButton.Text = "Start Timer";

startButton.Location = new Point(20, 60);

startButton.Click += new EventHandler(StartButton_Click);

// Stop Button create karte hain

Button stopButton = new Button();


stopButton.Text = "Stop Timer";

stopButton.Location = new Point(120, 60);

stopButton.Click += new EventHandler(StopButton_Click);

// Form mein Label aur Buttons add karte hain

this.Controls.Add(myLabel);

this.Controls.Add(startButton);

this.Controls.Add(stopButton);

private void MyTimer_Tick(object sender, EventArgs e)

counter++;

myLabel.Text = "Counter: " + counter;

private void StartButton_Click(object sender, EventArgs e)

counter = 0;

myLabel.Text = "Counter: 0";

myTimer.Start(); // Timer ko start karta hai

private void StopButton_Click(object sender, EventArgs e)

myTimer.Stop(); // Timer ko stop karta hai


}

[STAThread]

public static void Main()

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.

Use Cases of Timer Control

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.

4. Animation and UI Effects:

- 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.

# Common Properties of MenuStrip

1. Items:

- MenuStrip mein different menu items ko add ya manage karta hai.

- Example:

```csharp

myMenuStrip.Items.Add(fileMenuItem);

```

2. LayoutStyle:

- MenuStrip ke layout ko control karta hai.

- Example:

```csharp

myMenuStrip.LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow;

```

# Common Menu Items and Events

- 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.

Example: Creating a MenuStrip in Windows Forms

Yahan ek example hai jisme hum MenuStrip ka use kar rahe hain:

```csharp

using System;

using System.Windows.Forms;

public class MyForm : Form

private MenuStrip myMenuStrip;

public MyForm()

// MenuStrip create aur configure karte hain

myMenuStrip = new MenuStrip();

// File MenuItem create karte hain

ToolStripMenuItem fileMenuItem = new ToolStripMenuItem("File");

ToolStripMenuItem newMenuItem = new ToolStripMenuItem("New");

ToolStripMenuItem openMenuItem = new ToolStripMenuItem("Open");

ToolStripMenuItem exitMenuItem = new ToolStripMenuItem("Exit");


// Exit menu item par click event handle karte hain

exitMenuItem.Click += new EventHandler(ExitMenuItem_Click);

// File menu mein items add karte hain

fileMenuItem.DropDownItems.Add(newMenuItem);

fileMenuItem.DropDownItems.Add(openMenuItem);

fileMenuItem.DropDownItems.Add(new ToolStripSeparator()); // Separator line add


karta hai

fileMenuItem.DropDownItems.Add(exitMenuItem);

// MenuStrip mein File menu item add karte hain

myMenuStrip.Items.Add(fileMenuItem);

// Form mein MenuStrip add karte hain

this.MainMenuStrip = myMenuStrip;

this.Controls.Add(myMenuStrip);

private void ExitMenuItem_Click(object sender, EventArgs e)

Application.Exit(); // Application ko exit karta hai

[STAThread]

public static void Main()

{
Application.EnableVisualStyles();

Application.Run(new MyForm());

```

Is example mein:

- MenuStrip create kiya gaya hai jisme File menu add kiya gaya hai.

- File menu ke andar different options hain: `New`, `Open`, `Exit`.

- Exit option par click karne se application close ho jati hai.

2. ContextMenuStrip Control

ContextMenuStrip ek right-click context menu hai jo kisi specific control ke saath


associated hota hai. Yeh menu tab visible hota hai jab user kisi control par right-click karta
hai.

# Common Properties of ContextMenuStrip

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 class MyForm : Form

private ContextMenuStrip myContextMenuStrip;

private TextBox myTextBox;

public MyForm()

// TextBox create aur configure karte hain

myTextBox = new TextBox();

myTextBox.Location = new System.Drawing.Point(20, 20);

myTextBox.Width = 200;

// ContextMenuStrip create karte hain

myContextMenuStrip = new ContextMenuStrip();

myContextMenuStrip.Items.Add("Cut", null, Cut_Click);

myContextMenuStrip.Items.Add("Copy", null, Copy_Click);

myContextMenuStrip.Items.Add("Paste", null, Paste_Click);


// TextBox mein context menu attach karte hain

myTextBox.ContextMenuStrip = myContextMenuStrip;

// Form mein TextBox add karte hain

this.Controls.Add(myTextBox);

private void Cut_Click(object sender, EventArgs e)

myTextBox.Cut(); // TextBox mein text cut karta hai

private void Copy_Click(object sender, EventArgs e)

myTextBox.Copy(); // TextBox mein text copy karta hai

private void Paste_Click(object sender, EventArgs e)

myTextBox.Paste(); // Clipboard ka text paste karta hai

[STAThread]

public static void Main()

Application.EnableVisualStyles();
Application.Run(new MyForm());

```

Is example mein:

- TextBox create kiya gaya hai jisme ek ContextMenuStrip attach kiya gaya hai.

- ContextMenuStrip mein options hain: `Cut`, `Copy`, `Paste`.

- Jab user TextBox par right-click karta hai, toh yeh context menu options dikhai dete hain
jisse woh text manipulate kar sakta hai.

Use Cases of Menus

1. MenuStrip for Application Commands:

- MenuStrip ka use application ke commands ya options ko organize karne ke liye hota


hai, jaise File, Edit, View, Help.

2. ContextMenuStrip for Specific Controls:

- 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.

3. Navigation and User Guidance:

- 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.

- ToolStripMenuItem ek individual item hota hai jo MenuStrip ya ContextMenuStrip mein


add hota hai.

- 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.

Built-in Dialog Boxes:


Built-in Dialog Boxes Windows Forms mein predefined, ready-to-use dialogs hain jinka use
common tasks jaise files open/save karna, colors select karna, fonts choose karna, ya
messages dikhane ke liye hota hai. Yeh dialogs predefined controls aur functionality
provide karte hain jisse developer ka kaam asaan ho jata hai kyunki custom dialogs banane
ki zarurat nahi hoti.

Common Built-in Dialog Boxes in Windows Forms

1. MessageBox: User ko simple messages, warnings, ya prompts dikhane ke liye.

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.

# Example: Using MessageBox in Windows Forms

```csharp

MessageBox.Show("This is a simple message.", "Information", MessageBoxButtons.OK,


MessageBoxIcon.Information);

```

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.

# Common Properties of OpenFileDialog


1. Filter:

- File type filter set karta hai jisse user ko specific file types select karne ka option mile.

- Example:

```csharp

openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";

```

2. InitialDirectory:

- Dialog ke open hone par initial directory set karta hai.

- Example:

```csharp

openFileDialog.InitialDirectory = @"C:\";

```

# Example: Using OpenFileDialog in Windows Forms

```csharp

OpenFileDialog openFileDialog = new OpenFileDialog();

openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";

if (openFileDialog.ShowDialog() == DialogResult.OK)

string filePath = openFileDialog.FileName;

MessageBox.Show("Selected File: " + filePath);

```
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.

# Example: Using SaveFileDialog in Windows Forms

```csharp

SaveFileDialog saveFileDialog = new SaveFileDialog();

saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";

if (saveFileDialog.ShowDialog() == DialogResult.OK)

string filePath = saveFileDialog.FileName;

MessageBox.Show("File will be saved at: " + filePath);

```

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.

# Example: Using ColorDialog in Windows Forms


```csharp

ColorDialog colorDialog = new ColorDialog();

if (colorDialog.ShowDialog() == DialogResult.OK)

this.BackColor = colorDialog.Color; // Selected color ko form ka background set karta hai

```

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.

# Example: Using FontDialog in Windows Forms

```csharp

FontDialog fontDialog = new FontDialog();

if (fontDialog.ShowDialog() == DialogResult.OK)

myLabel.Font = fontDialog.Font; // Selected font ko label ke liye set karta hai

```

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.

# Example: Using FolderBrowserDialog in Windows Forms

```csharp

FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

if (folderBrowserDialog.ShowDialog() == DialogResult.OK)

string selectedPath = folderBrowserDialog.SelectedPath;

MessageBox.Show("Selected Folder: " + selectedPath);

```

Summary of Built-in Dialog Boxes

1. MessageBox: User ko simple messages, prompts, ya warnings dikhane ke liye.

2. OpenFileDialog: User ko ek file select karne ke liye.

3. SaveFileDialog: User ko ek file save karne ke liye.

4. ColorDialog: User ko color select karne ke liye.

5. FontDialog: User ko font select karne ke liye.

6. FolderBrowserDialog: User ko ek folder select karne ke liye.


Built-in Dialog Boxes Windows Forms applications mein developer ka kaam asaan banate
hain kyunki yeh predefined functionality provide karte hain jo common tasks jaise file
operations, color selection, font selection, etc. ko asaani se handle karne mein madad
karte hain. Yeh dialogs application ko user-friendly banate hain aur achha user experience
provide karte hain.

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.

Common Printing Components in Windows Forms

1. PrintDocument: Primary class jo print operation ko handle karti hai.

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.

# Example: Using PrintDocument in Windows Forms


```csharp

using System;

using System.Drawing;

using System.Drawing.Printing;

using System.Windows.Forms;

public class MyForm : Form

private PrintDocument myPrintDocument;

public MyForm()

// Button to start the print process

Button printButton = new Button();

printButton.Text = "Print Document";

printButton.Location = new Point(20, 20);

printButton.Click += new EventHandler(PrintButton_Click);

// PrintDocument create karte hain

myPrintDocument = new PrintDocument();

myPrintDocument.PrintPage += new
PrintPageEventHandler(PrintDocument_PrintPage);

// Form mein button add karte hain

this.Controls.Add(printButton);
}

private void PrintButton_Click(object sender, EventArgs e)

// PrintDialog show karte hain

PrintDialog printDialog = new PrintDialog();

printDialog.Document = myPrintDocument;

if (printDialog.ShowDialog() == DialogResult.OK)

myPrintDocument.Print(); // Printing process start karta hai

private void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)

// PrintPage event mein specify karte hain kya print karna hai

string printText = "Hello, this is a test print!";

Font printFont = new Font("Arial", 12);

PointF printLocation = new PointF(100, 100);

e.Graphics.DrawString(printText, printFont, Brushes.Black, printLocation);

[STAThread]

public static void Main()

{
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.

# Example: Using PrintDialog

```csharp

PrintDialog printDialog = new PrintDialog();

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.

# Example: Using PageSetupDialog

```csharp

PageSetupDialog pageSetupDialog = new PageSetupDialog();

pageSetupDialog.Document = myPrintDocument;

if (pageSetupDialog.ShowDialog() == DialogResult.OK)

// Page settings apply kiye ja sakte hain

```

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 printPreviewDialog = new PrintPreviewDialog();

printPreviewDialog.Document = myPrintDocument;

printPreviewDialog.ShowDialog(); // Print preview show karta hai

```

Printing Flow in Windows Forms

1. Page Setup (Optional): User PageSetupDialog ke through page layout set karta hai.

2. Print Preview (Optional): PrintPreviewDialog ke through user ko print ka preview dikhaya


jaata 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.

ImageList Control ka Overview

- 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.

Common Properties of ImageList

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:

- Image ke color depth ko define karta hai, jaise `Depth8Bit`, `Depth16Bit`,


`Depth24Bit`, `Depth32Bit`.

- Example:

```csharp

myImageList.ColorDepth = ColorDepth.Depth32Bit; // Image quality improve karne ke


liye 32-bit color depth set karta hai

```

Common Methods of ImageList

1. Images.Add():

- ImageList mein ek image add karta hai.

- Example:
```csharp

myImageList.Images.Add(Image.FromFile("path/to/image.png"));

```

2. Images.RemoveAt():

- Specified index se image ko remove karta hai.

- Example:

```csharp

myImageList.Images.RemoveAt(0); // Index 0 se image remove karta hai

```

3. Images.Clear():

- Saari images ko ImageList se remove karta hai.

- Example:

```csharp

myImageList.Images.Clear(); // Saari images remove karta hai

```

Using ImageList with Other Controls

ImageList ko commonly ListView, TreeView, ya Button jaison ke saath use kiya jaata hai
taaki unmein images ya icons add kiye ja saken.

# Example: Using ImageList with ListView


Yahan ek example hai jisme hum ImageList ka use ek ListView control ke saath kar rahe
hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private ImageList myImageList;

private ListView myListView;

public MyForm()

// ImageList create aur configure karte hain

myImageList = new ImageList();

myImageList.ImageSize = new Size(32, 32);

myImageList.Images.Add(Image.FromFile("path/to/image1.png"));

myImageList.Images.Add(Image.FromFile("path/to/image2.png"));

// ListView create aur configure karte hain

myListView = new ListView();

myListView.Location = new Point(20, 20);

myListView.Size = new Size(200, 150);

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);

// Form mein ListView add karte hain

this.Controls.Add(myListView);

[STAThread]

public static void Main()

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.

Use Cases of ImageList

1. ListView Control ke saath Icons Add Karna:

- 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.

2. TreeView Control ke Nodes ke saath Icons:

- 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.

3. Toolbars aur Buttons mein Icons Dikhana:

- 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.

Tree and List Views:


TreeView aur ListView Windows Forms mein commonly used controls hain jinka use data
ko visually hierarchical ya list format mein dikhane ke liye hota hai. Yeh dono controls user-
friendly aur well-organized UI elements banane mein madad karte hain, jisme user asaani
se interact kar sakta 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.

# Common Properties of TreeView

1. Nodes:

- TreeView ke andar root nodes aur child nodes ko represent karta hai.

- Example:

```csharp

myTreeView.Nodes.Add("Root Node"); // Ek root node add karta hai

```
2. ImageList:

- TreeView ke nodes ke saath icons add karne ke liye use hoti hai.

- Example:

```csharp

myTreeView.ImageList = myImageList; // Node ke saath icons associate karne ke liye

```

3. SelectedNode:

- Yeh property currently selected node ko represent karti hai.

- Example:

```csharp

var selectedNode = myTreeView.SelectedNode; // Currently selected node get karta hai

```

# Common Events of TreeView

1. AfterSelect:

- Jab user kisi node ko select karta hai, toh yeh event trigger hota hai.

- Example:

```csharp

myTreeView.AfterSelect += new TreeViewEventHandler(MyTreeView_AfterSelect);

private void MyTreeView_AfterSelect(object sender, TreeViewEventArgs e)

MessageBox.Show("Selected Node: " + e.Node.Text);


}

```

# Example: Using TreeView in Windows Forms

```csharp

using System;

using System.Windows.Forms;

public class MyForm : Form

private TreeView myTreeView;

public MyForm()

// TreeView create aur configure karte hain

myTreeView = new TreeView();

myTreeView.Location = new System.Drawing.Point(20, 20);

myTreeView.Size = new System.Drawing.Size(200, 200);

// TreeView mein nodes add karte hain

TreeNode rootNode = new TreeNode("Root Node");

TreeNode childNode1 = new TreeNode("Child Node 1");

TreeNode childNode2 = new TreeNode("Child Node 2");

rootNode.Nodes.Add(childNode1);
rootNode.Nodes.Add(childNode2);

myTreeView.Nodes.Add(rootNode);

// TreeView ke event ko handle karte hain

myTreeView.AfterSelect += new TreeViewEventHandler(MyTreeView_AfterSelect);

// Form mein TreeView add karte hain

this.Controls.Add(myTreeView);

private void MyTreeView_AfterSelect(object sender, TreeViewEventArgs e)

MessageBox.Show("Selected Node: " + e.Node.Text);

[STAThread]

public static void Main()

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.

Use Cases of TreeView

1. File Explorer:

- Folder structure dikhane ke liye jahan folders aur subfolders hierarchical view mein
dikhai dete hain.

2. Organizational Structure:

- Kisi organization ke hierarchy ya departments ko visualize karne ke liye.

3. Navigation Menus:

- Application ke different sections ko represent karne ke liye jahan user expand/collapse


karke details dekh sakta hai.

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.

# View Modes of ListView

1. LargeIcon: Items ko large icons ke saath dikhata hai.

2. SmallIcon: Items ko small icons ke saath dikhata hai.

3. List: Items ko ek vertical list mein dikhata hai.

4. Details: Items ko columns ke saath tabular format mein dikhata hai.


5. Tile: Items ko tile format mein dikhata hai (jaise large icon aur text details ke saath).

# Common Properties of ListView

1. View:

- ListView ke items ka view mode set karta hai.

- Example:

```csharp

myListView.View = View.Details; // Items ko details ke saath dikhata hai

```

2. Columns:

- ListView mein columns add karta hai jab view mode Details ho.

- Example:

```csharp

myListView.Columns.Add("Name", 100); // "Name" column add karta hai width 100 ke


saath

```

3. Items:

- ListView mein items add karta hai.

- Example:

```csharp

myListView.Items.Add(new ListViewItem("Item 1"));

```
# 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);

private void MyListView_SelectedIndexChanged(object sender, EventArgs e)

if (myListView.SelectedItems.Count > 0)

MessageBox.Show("Selected Item: " + myListView.SelectedItems[0].Text);

```

# Example: Using ListView in Windows Forms

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form


{

private ListView myListView;

public MyForm()

// ListView create aur configure karte hain

myListView = new ListView();

myListView.Location = new Point(20, 20);

myListView.Size = new Size(300, 200);

myListView.View = View.Details;

// ListView mein columns add karte hain

myListView.Columns.Add("Name", 100);

myListView.Columns.Add("Age", 50);

// ListView mein items add karte hain

myListView.Items.Add(new ListViewItem(new string[] { "Alice", "25" }));

myListView.Items.Add(new ListViewItem(new string[] { "Bob", "30" }));

// ListView ke event ko handle karte hain

myListView.SelectedIndexChanged += new
EventHandler(MyListView_SelectedIndexChanged);

// Form mein ListView add karte hain

this.Controls.Add(myListView);

}
private void MyListView_SelectedIndexChanged(object sender, EventArgs e)

if (myListView.SelectedItems.Count > 0)

MessageBox.Show("Selected Item: " + myListView.SelectedItems[0].Text);

[STAThread]

public static void Main()

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.

- SelectedIndexChanged event ke through, selected item ka text MessageBox mein dikhaya


jaata hai.

Use Cases of ListView


1. File Manager:

- 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.

- Use Cases: File explorer, organizational hierarchy, navigation menus.

- ListView tabular ya list format mein data ko dikhata hai jisme multiple views ho sakte hain
(details, icons).

- Use Cases: File manager, contact lists, data tables.

- 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.

Common Elements of ToolStrip

1. ToolStripButton: Ek button jisko ToolStrip mein add kiya ja sakta hai.

2. ToolStripSeparator: Ek line jo buttons ko visually separate karne ke liye use hoti hai.

3. ToolStripDropDownButton: Ek button jisme drop-down menu ho sakta hai jisse multiple


options dikhayi ja sakti hain.

4. ToolStripLabel: Label jiska use text display karne ke liye hota hai.

Common Properties of ToolStrip

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;

```

Example: Creating a ToolStrip in Windows Forms

Yahan ek example hai jisme hum ToolStrip ka use kar rahe hain:

```csharp

using System;

using System.Drawing;

using System.Windows.Forms;

public class MyForm : Form

private ToolStrip myToolStrip;

public MyForm()

// ToolStrip create aur configure karte hain


myToolStrip = new ToolStrip();

// ToolStripButton "New" create karte hain

ToolStripButton newButton = new ToolStripButton("New");

newButton.Click += new EventHandler(NewButton_Click);

// ToolStripButton "Open" create karte hain

ToolStripButton openButton = new ToolStripButton("Open");

openButton.Click += new EventHandler(OpenButton_Click);

// ToolStripButton "Save" create karte hain

ToolStripButton saveButton = new ToolStripButton("Save");

saveButton.Click += new EventHandler(SaveButton_Click);

// ToolStripSeparator add karte hain

ToolStripSeparator separator = new ToolStripSeparator();

// ToolStrip mein buttons aur separator add karte hain

myToolStrip.Items.Add(newButton);

myToolStrip.Items.Add(openButton);

myToolStrip.Items.Add(separator);

myToolStrip.Items.Add(saveButton);

// Form mein ToolStrip add karte hain

this.Controls.Add(myToolStrip);

}
private void NewButton_Click(object sender, EventArgs e)

MessageBox.Show("New button clicked");

private void OpenButton_Click(object sender, EventArgs e)

MessageBox.Show("Open button clicked");

private void SaveButton_Click(object sender, EventArgs e)

MessageBox.Show("Save button clicked");

[STAThread]

public static void Main()

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.

Use Cases of Toolbars

1. Quick Access to Common Commands:

- 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.

2. Icons for Better User Experience:

- 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.

3. Text and Icon Combination:

- ToolStripButton mein icons ke saath text bhi dikhaya ja sakta hai jisse button ka function
clear ho jaye.

Customizing ToolStrip

1. Adding Images to Buttons:

- Images ko buttons ke saath add karne ke liye ToolStripButton ki Image property set ki ja
sakti hai.

- Example:
```csharp

ToolStripButton saveButton = new ToolStripButton();

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

ToolStripDropDownButton optionsButton = new ToolStripDropDownButton("Options");

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 and Progress Bars, and Tab Controls:

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.

# Common Elements of StatusStrip

1. ToolStripStatusLabel: Status strip mein label jisme text ya information display ki ja sakti
hai.

2. ToolStripProgressBar: Ek progress bar jo status strip mein dikhai de sakta hai.

# Example: Using StatusStrip in Windows Forms


```csharp

using System;

using System.Windows.Forms;

public class MyForm : Form

private StatusStrip myStatusStrip;

public MyForm()

// StatusStrip create aur configure karte hain

myStatusStrip = new StatusStrip();

// ToolStripStatusLabel create karte hain

ToolStripStatusLabel statusLabel = new ToolStripStatusLabel("Ready");

myStatusStrip.Items.Add(statusLabel);

// Form mein StatusStrip add karte hain

this.Controls.Add(myStatusStrip);

[STAThread]

public static void Main()

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.

Use Cases of StatusBar

1. Current Status Display:

- Application ke current status, jaise "Ready", "Loading...", ya "Processing complete"


show karne ke liye.

2. User Interaction Feedback:

- 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.

# Common Properties of ProgressBar

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:

- Progress bar ki current progress set karta hai.

- Example:

```csharp

myProgressBar.Value = 50; // 50% complete

```

# Example: Using ProgressBar in Windows Forms

```csharp

using System;

using System.Windows.Forms;

public class MyForm : Form


{

private ProgressBar myProgressBar;

private Button startButton;

public MyForm()

// ProgressBar create aur configure karte hain

myProgressBar = new ProgressBar();

myProgressBar.Location = new System.Drawing.Point(20, 20);

myProgressBar.Width = 200;

myProgressBar.Minimum = 0;

myProgressBar.Maximum = 100;

// Button create karte hain progress start karne ke liye

startButton = new Button();

startButton.Text = "Start Progress";

startButton.Location = new System.Drawing.Point(20, 60);

startButton.Click += new EventHandler(StartButton_Click);

// Form mein ProgressBar aur Button add karte hain

this.Controls.Add(myProgressBar);

this.Controls.Add(startButton);

private void StartButton_Click(object sender, EventArgs e)

{
myProgressBar.Value = 50; // Example: progress ko 50% set karte hain

[STAThread]

public static void Main()

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.

Use Cases of ProgressBar

1. File Downloads or Uploads:

- Kisi file download/upload hone ki progress show karne ke liye.

2. Loading Screens:

- Data loading, installations, ya background processes ki progress show karne ke liye.

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.

# Common Elements of TabControl

1. TabPage: TabControl mein har tab ko represent karta hai, jisme different controls aur
content ho sakta hai.

2. TabPages: TabControl mein pages ka collection.

# Example: Using TabControl in Windows Forms

```csharp

using System;

using System.Windows.Forms;

public class MyForm : Form

private TabControl myTabControl;

public MyForm()

// TabControl create aur configure karte hain

myTabControl = new TabControl();

myTabControl.Location = new System.Drawing.Point(20, 20);

myTabControl.Size = new System.Drawing.Size(300, 200);


// TabPages create karte hain

TabPage tabPage1 = new TabPage("Tab 1");

TabPage tabPage2 = new TabPage("Tab 2");

// TabControl mein TabPages add karte hain

myTabControl.TabPages.Add(tabPage1);

myTabControl.TabPages.Add(tabPage2);

// Form mein TabControl add karte hain

this.Controls.Add(myTabControl);

[STAThread]

public static void Main()

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.

Use Cases of TabControl


1. Forms with Multiple Sections:

- 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

1. Status Bars (StatusStrip):

- StatusStrip ka use application ke current status ya messages display karne ke liye hota
hai.

- Common elements: ToolStripStatusLabel, ToolStripProgressBar.

2. Progress Bars:

- ProgressBar kisi ongoing task ya process ki progress show karta hai.

- Useful for: File downloads, loading screens, task completion status.

3. Tab Controls:

- TabControl ek tabbed interface create karta hai jisme multiple pages ya sections hoti
hain.

- Useful for: Organizing related sections, user navigation.

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.

You might also like