C# (C-Sharp) is a programming language developed by Microsoft that runs on the .NET Framework. And used to develop web application, desktop application, mobile application, games application and much more.
C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg.
This tutorial is how to get list of printer name installed in your PC using C# Development.
Please follow the steps.
- First Create a project to in VS (Visual Studio);
Click file and New then Project.
- After that Please follow this steps.
- Click or select Visual C#
- At this point I choice Windows Form App (.NET Framework).
- Create project name “getListPrinterName“
- Then Ok;
- after the project begin.
- add DataGridView to the form to display the list of all Printer name install from you PC’s
- And Button function for Get Execution.
- Now lets Start to the Code. and first install the library that can get PrinterSettings
- Goto Manage NuGets Package
- and search and Install “System.Drawing.Common”
- Code
DataTable dt = new DataTable(); // declate datatable for temp. storage
dt.Columns.Add("PrinterName"); // add column in datatable
foreach (String printer in PrinterSettings.InstalledPrinters) // loop all printer properties get from your PC
{
dt.Rows.Add(printer.ToString()); // stored printer name datatable
}
dataGridView1.DataSource = dt; // display all data from datatable to datagridview
- Sample View
You can freely comment your idea to any suggestion for this blog. thank you and hoping can give a input knowledge for everyone.
Related Topics
How to compose email and save email draft in outlook using C#
How to compose email and save email draft in outlook using C# […]
How to convert base64 string format of excel file into DataTable form of data type using C#
In this article, We learn how to convert base64 string format of excel file into Data Table form of data type using C#. I will […]
How to convert data from Aspose.Cells.Worksheet to DataTable using C#
How to conversion of data from Aspose.Cells.Worksheet to DataTable using C# […]
Awesome
Thank you for feedback. Please subscribe to get notify for new update and upload.
Nice Job!
Thank you for feedback. Please subscribe to get notify for new update and upload.