C#•Create a Round Box Around ListBox

Listing 2. Create the round box around the ListBox control by inflating the edges of the rectangle that represents the box you're creating. You aren't actually rounding the edges of the ListBox; you're creating a round box around a ListBox that has no border.

private void Form1_Paint(object sender, 
   System.Windows.Forms.PaintEventArgs e)

   // Get a Rectangle object that represents 
   // the bounds of the ListBox
   Rectangle rect = this.listBox1.Bounds;

   // Call the Inflate method, which can inflate 
   // the rectangle, or take a height and width 
   // to expand the bounds of the listbox with 
   // circular edges

   // Draw the GraphicsPath object 
   // around the Listbox.  
   // The GetRoundBox method takes 
   // the rectangle of the Listbox 
   // and the roundness for the corners
      this.GetRoundBox(rect, 10));