Lucyberad
Messages postés414Date d'inscriptionmercredi 16 juin 2004StatutMembreDernière intervention26 juillet 2007
-
17 janv. 2006 à 19:45
Lucyberad
Messages postés414Date d'inscriptionmercredi 16 juin 2004StatutMembreDernière intervention26 juillet 2007
-
17 janv. 2006 à 22:53
Bonjour a tous,
J'aimerais savoir comment je peut faire pour faire des combobox comme celle visual studio.
exemple: celle de dock qui comprend 6 boutons. ou meme celle de transparency key qui affiche un tableau de choix de couleur. ou meme celle de accesible role qui comprend une listbox.
Sinon, pour les couleur, il faut refaire la presonalisation du combo.
Example:
Public Class ColorCombo
Inherits System.Windows.Forms.ComboBox
Public Enum ColorType As Integer
Web = 1
System = 2
End Enum
Private m_ColorType As ColorType = ColorType.Web
Public Property ShowColorType() As ColorType
Get
Return MyClass.m_ColorType
End Get
Set(ByVal value As ColorType)
MyClass.m_ColorType = value
Call SetListColor()
End Set
End Property
Public Sub New()
MyBase.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
MyBase.DropDownStyle = ComboBoxStyle.DropDownList
MyBase.DisplayMember = "Name"
Call SetListColor()
End Sub
Private Sub SetListColor()
MyBase.Items.Clear()
If CBool(MyClass.m_ColorType And ColorType.Web) Then
For Each PropertyInfo As System.Reflection.PropertyInfo In GetType(System.Drawing.Color).GetProperties
Try
Dim Color As System.Drawing.Color = CType(PropertyInfo.GetValue(GetType(System.Drawing.Color), Nothing), System.Drawing.Color)
MyBase.Items.Add(Color)
Catch
End Try
Next
End If
If CBool(MyClass.m_ColorType And ColorType.System) Then
For Each PropertyInfo As System.Reflection.PropertyInfo In GetType(System.Drawing.SystemColors).GetProperties
Try
Dim Color As System.Drawing.Color = CType(PropertyInfo.GetValue(GetType(System.Drawing.Color), Nothing), System.Drawing.Color)
MyBase.Items.Add(Color)
Catch
End Try
Next
End If
End Sub
Protected Overrides Sub OnDrawItem(ByVal e As System.Windows.Forms.DrawItemEventArgs)
If e.Index > -1 Then
e.DrawBackground()
If MyBase.Items(e.Index).GetType Is GetType(System.Drawing.Color) Then
Dim Color As System.Drawing.Color = CType(MyBase.Items(e.Index), System.Drawing.Color)
e.Graphics.FillRectangle(New System.Drawing.SolidBrush(Color), New System.Drawing.Rectangle(e.Bounds.Left + 2, e.Bounds.Top + 2, e.Bounds.Height - 4, e.Bounds.Height - 4))
e.Graphics.DrawRectangle(System.Drawing.SystemPens.WindowText, New System.Drawing.Rectangle(e.Bounds.Left + 1, e.Bounds.Top + 1, e.Bounds.Height - 3, e.Bounds.Height - 3))
e.Graphics.DrawString(Color.Name, e.Font, New System.Drawing.SolidBrush(e.ForeColor), e.Bounds.Left + e.Bounds.Height + 2, e.Bounds.Top + CInt((e.Bounds.Height - e.Graphics.MeasureString(Color.Name, e.Font).Height) / 2))
ElseIf MyBase.Items(e.Index).GetType Is GetType(String) Then
e.Graphics.DrawString(CStr(MyBase.Items(e.Index)), e.Font, New System.Drawing.SolidBrush(e.ForeColor), e.Bounds.Left + 2, e.Bounds.Top + CInt((e.Bounds.Height - e.Graphics.MeasureString(CStr(MyBase.Items(e.Index)), e.Font).Height) / 2))
End If
End If
MyBase.OnDrawItem(e)
End Sub
End Class
Pour le checkBox, va voir ma source http://www.vbfrance.com/code.aspx?ID=34099, c'est pour une listbox, mais c'est le même principe pour un combo. Tu as juste à changer 2,3 trucs
Voili, voilou
Kenji
<hr size="2" width="100%">
Merci de cliquer sur "Réponse acceptée" si une réponse vous convient.
Lucyberad
Messages postés414Date d'inscriptionmercredi 16 juin 2004StatutMembreDernière intervention26 juillet 20073 17 janv. 2006 à 22:46
alors justement c'est suite a la reponse que tu as apporté a mon sujet precendent, en effet il m'est revenu une technique que j'avais vu dans une petite video du dev days 2005 (ici) quand le mec integre un calendar dans un toolstrip, j'ai finalement pensé a ce procedé quand j'ai essayé de faire un controle, quand je touchait a la propriété dock.
j'ai peut-etre pensé en fait que ce procédé pouvait etre appliqué a mon cas vu precedement, qu'on as commencé hier (ou avant-hier).
en effet pour faire plus clair, si on pouvait faire a la place d'afficher le truc des couleur ou la listbox, afficher un panel !
Lucyberad
Messages postés414Date d'inscriptionmercredi 16 juin 2004StatutMembreDernière intervention26 juillet 20073 17 janv. 2006 à 22:53
Ha oui sinon j'oublais, donc si je veut refaire comme j'ai dit dans le precedent post, il faut en fait refaire un boutin ? et ce boutin aficherai le debut de ce qui se trouve dedans.
ok je comprend mieux !