Sunday, July 23, 2006 2:22 PM
Is thre any property the centeralize the text in combobox in the center?
I know that in text box there is propert alignment,
but in combobox I don't find any property who do that?
Sunday, July 23, 2006 3:48 PMModerator
Monday, July 24, 2006 5:37 PMModeratorAdd a new class to your project, then paste this code:
Public Class CenteredComboBox
Me.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
Me.DropDownStyle = ComboBoxStyle.DropDownList
Private Sub CenteredComboBox_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
Dim txt As String = ""
If e.Index >= 0 Then txt = Me.Items(e.Index).ToString
TextRenderer.DrawText(e.Graphics, txt, e.Font, e.Bounds, e.ForeColor, TextFormatFlags.HorizontalCenter)
Build your project. Now you can put CenteredComboBox controls on your form. Please note that the text box portion of the control is only centered when you use the DropDownList style.
Monday, March 03, 2008 6:55 PM
NoBugs: That was TOTALLY FLAWLESS and RIGHT ON TIME! THANK YOU!