Skip to content

Archive

Archive for October 12th, 2009

Get all printers listing in C#

Oct 12
Uncategorized

Import System.Drawing.Printing namespace in your application.

using System.Drawing.Printing;

Add a DropDownList and change its name to printersList and write this below code on Form’s load event handler.

private void Form1_Load (object sender, System.EventArgs e)
{
 foreach (String printer in PrinterSettings.InstalledPrinters)
           {
                    printersList.Items.Add (printer.ToString());
           }
}

The DropDownList will show all printers available on your network.

Dynamically add a button in DataGrid C # language easy
DataGridViewButtonColumn AddButton = new DataGridViewButtonColumn();
            AddButton.Name = "AddButton";
            AddButton.HeaderText = "AddButton";
            AddButton.Text = "AddButton";
            AddButton.Width = 70;
            AddButton.UseColumnTextForButtonValue = true;
            DataGrid.Columns.Add(AddButton);

Slider by webdesign