2009-08-28 6 views

Répondre

1

Modifier ComboBox "rightToLeft" propriété TRUE.

Remarque: La flèche déroulante se trouve maintenant sur le côté gauche du contrôle.

+0

je l'ai mentionné, j'essayé et didn Je n'aime pas le look. – Cheeso

1

Je mis l'événement DrawItem sur le combobox. Également mis en

this.comboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; 

Ce code j'ai utilisé pour DrawItem:

private void comboBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) 
    { 
     var rc = new System.Drawing.Rectangle(e.Bounds.X , e.Bounds.Y, 
            e.Bounds.Width, e.Bounds.Height); 

     var sf = new System.Drawing.StringFormat 
     { 
      Alignment = System.Drawing.StringAlignment.Far 
     }; 

     string str = (string)comboBox1.Items[e.Index]; 

     if (e.State == (DrawItemState.Selected | DrawItemState.NoAccelerator 
          | DrawItemState.NoFocusRect) || 
      e.State == DrawItemState.Selected) 
     { 
      e.Graphics.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.CornflowerBlue), rc); 
      e.Graphics.DrawString(str, this.comboBox1.Font, new System.Drawing.SolidBrush(System.Drawing.Color.Cyan), rc, sf); 
     } 
     else 
     { 
      e.Graphics.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.White), rc); 
      e.Graphics.DrawString(str, this.comboBox1.Font, new System.Drawing.SolidBrush(System.Drawing.Color.Black), rc, sf); 
     } 
    } 

C'est ce qu'il ressemble à:

alt text http://i25.tinypic.com/mwv8qx.jpg

Questions connexes