Torna al Thread

Public Class Form1 Dim CBitems As New ArrayList Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load CBitems.Add("pippo") CBitems.Add("pippa...") CBitems.Add("orazio") CBitems.Add("clarabella") CBitems.Add("paperone") CBitems.Add("qui") CBitems.Add("quo") CBitems.Add("qua") CBitems.Add("paperino") CBitems.Add("paperina") CBitems.Add("topolino") CBitems.Add("topolina") CBitems.Add("eta beta") CBitems.Add("archimede") CBquadrati_init() End Sub #Region "CBquadrati" Private Sub CBquadrati_init() CBquadrati.Items.AddRange(CBitems.ToArray) CBquadrati.DrawMode = DrawMode.OwnerDrawVariable CBquadrati.DropDownStyle = ComboBoxStyle.DropDown CBquadrati.AutoCompleteMode = AutoCompleteMode.Suggest CBquadrati.AutoCompleteSource = AutoCompleteSource.ListItems End Sub Private Sub CBquadrati_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CBquadrati.KeyDown If e.KeyCode = Keys.Up Or e.KeyCode = Keys.Down _ Or e.KeyCode = Keys.Left Or e.KeyCode = Keys.Right Then CBquadrati.DroppedDown = True Else CBquadrati.DroppedDown = False End If End Sub Private Sub CBquadrati_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles CBquadrati.DrawItem Dim coloreSfondoGrande As Color Dim coloreSfondoPicc As Color Dim coloreCarattere As System.Drawing.Brush If e.State = 1 Then coloreSfondoGrande = Color.MediumBlue coloreCarattere = Brushes.White If ((e.Index Mod 2) <> 0) Then coloreSfondoPicc = Color.Red Else coloreSfondoPicc = Color.Yellow End If End If If e.State = 0 Then coloreCarattere = Brushes.Black If ((e.Index Mod 2) <> 0) Then coloreSfondoGrande = Color.LightGray coloreSfondoPicc = Color.Red Else coloreSfondoGrande = Color.LightSlateGray coloreSfondoPicc = Color.Yellow End If End If e.DrawBackground() Dim rectangle_grande As Rectangle = New Rectangle(e.Bounds.Left, _ e.Bounds.Top, e.Bounds.Width, e.Bounds.Height) Dim rectangle_piccolo As Rectangle = New Rectangle(2, e.Bounds.Top + 2, _ e.Bounds.Height - 4, e.Bounds.Height - 4) e.Graphics.FillRectangle(New SolidBrush(coloreSfondoGrande), rectangle_grande) If e.State = 1 Then e.Graphics.FillEllipse(New SolidBrush(Color.LawnGreen), rectangle_piccolo) Else e.Graphics.FillRectangle(New SolidBrush(coloreSfondoPicc), rectangle_piccolo) End If e.Graphics.DrawString(CBquadrati.Items(e.Index), CBquadrati.Font, coloreCarattere, _ New RectangleF(e.Bounds.X + rectangle_piccolo.Width + 3, e.Bounds.Y, _ e.Bounds.Width, e.Bounds.Height)) End Sub #End Region End Class
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5