How to convert some codes from ComboBox to checklistbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • damtoii
    New Member
    • Jan 2014
    • 9

    How to convert some codes from ComboBox to checklistbox

    I'm trying to convert the combobox into a checklistbox . It is possible to debug of some codes to convert into checklistbox. ?

    here's my codes:


    Code:
    private void Form1_Load(object sender, EventArgs e)
            {
                //See if any printers are installed
                if (PrinterSettings.InstalledPrinters.Count <= 0)
                {
                    MessageBox.Show("Printer not found!");
                    return;
                }
    
                //Get all available printers and add them to the combo box
                foreach (String printer in PrinterSettings.InstalledPrinters)
                {
                    comboBox1.Items.Add(printer.ToString());
                }
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                 //Create a PrintDocument object
                PrintDocument pd = new PrintDocument();
    
                //Set PrinterName as the selected printer in the printers list
                pd.PrinterSettings.PrinterName = comboBox1.SelectedItem.ToString();
    
                //Add PrintPage event handler
                pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
    
                //Print the document
                pd.Print();
            }
    
            //The PrintPage event handler 
            public void pd_PrintPage(object sender, PrintPageEventArgs ev)
            {
    
                //Get the Graphics object
                Graphics g = ev.Graphics;
    
                //Create a font Arial with size 16
                Font font = new Font("Arial", 16);
    
                //Create a solid brush with black color
                SolidBrush brush = new SolidBrush(Color.Black);
    
                //Draw "Hello Printer!";
                g.DrawString("Hello Printer!",
                font, brush,
                new Rectangle(20, 20, 200, 100));
            }
        }
    Last edited by Rabbit; Jan 19 '14, 05:29 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...