Click here to Skip to main content
15,569,768 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionresizing form with a RTB inside Pin
hang_em3-Aug-11 0:58
hang_em3-Aug-11 0:58 
AnswerRe: resizing form with a RTB inside Pin
Dave Kreskowiak3-Aug-11 3:05
mveDave Kreskowiak3-Aug-11 3:05 
GeneralRe: resizing form with a RTB inside Pin
hang_em3-Aug-11 19:01
hang_em3-Aug-11 19:01 
GeneralRe: resizing form with a RTB inside Pin
Dave Kreskowiak3-Aug-11 19:39
mveDave Kreskowiak3-Aug-11 19:39 
GeneralRe: resizing form with a RTB inside Pin
hang_em4-Aug-11 4:24
hang_em4-Aug-11 4:24 
GeneralRe: resizing form with a RTB inside Pin
Dave Kreskowiak4-Aug-11 14:55
mveDave Kreskowiak4-Aug-11 14:55 
QuestionCallbackOnCollectedDelegate was detected with LowLevelMouserProc Pin
Member 78319591-Aug-11 12:46
Member 78319591-Aug-11 12:46 
QuestionFont ComboBox add to Toolstrip Pin
nyt197231-Jul-11 4:13
professionalnyt197231-Jul-11 4:13 
Hello Experts,

I am learning to make a font combobox and tried the following code, but how to add this combobox to the vb.net toolstrip. I am using vb.net 2005 Please help.

VB
Imports System.Drawing

Public Class FontClass
    Inherits ComboBox
    Dim wait As Boolean
    Public Sub New()
        Me.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
        Me.DropDownStyle = ComboBoxStyle.DropDownList
        Me.Text = ""
        Dim ff As FontFamily
        Dim fc As New FontConverter

        For Each ff In FontFamily.Families
            Dim comboitem As New ComboBoxItem
            If ff.IsStyleAvailable(FontStyle.Regular) Then
                comboitem.Text = ff.Name
                comboitem.Font = fc.ConvertFromString(ff.Name)
                Me.Items.Add(comboitem)

            End If
        Next

    End Sub

    Protected Overrides Sub OnDrawItem(ByVal e As System.Windows.Forms.DrawItemEventArgs)
        e.DrawBackground()
        e.DrawFocusRectangle()
        Dim item As New ComboBoxItem
        Dim bounds As New Rectangle
        bounds = e.Bounds
        Try
            item = Me.Items(e.Index)
            e.Graphics.DrawString(item.Text, item.Font, New SolidBrush(e.ForeColor), bounds.Left, bounds.Top)

        Catch ex As Exception
            If (e.Index <> -1) Then
                e.Graphics.DrawString((e.Index).ToString(), e.Font, New SolidBrush(e.ForeColor), bounds.Left, bounds.Top)
            Else
                e.Graphics.DrawString(Text, e.Font, New SolidBrush(e.ForeColor), bounds.Left, bounds.Top)
            End If

        End Try

        MyBase.OnDrawItem(e)
    End Sub

    Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
        wait = False
        MyBase.OnMouseLeave(e)
    End Sub

    Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
        wait = False
        MyBase.OnMouseUp(e)
    End Sub


    Protected Overrides Sub OnSelectedIndexChanged(ByVal e As System.EventArgs)
        Try
            If wait = False Then
                Dim fc As New FontConverter

                Me.Font = fc.ConvertFromString(Me.Text)
            End If
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try
    End Sub
    


End Class

Public Class ComboBoxItem

    Private ctext As String
    Private cSelFont As Font

    Property Text() As String
        Get
            Return ctext
        End Get
        Set(ByVal Value As String)
            ctext = Value
        End Set
    End Property
    Property Font() As Font
        Get
            Return cSelFont
        End Get
        Set(ByVal Value As Font)
            cSelFont = Value
        End Set
    End Property
    Public Overrides Function ToString() As String
        Return ctext
    End Function



End Class


Thanks in advance.
AnswerRe: Font ComboBox add to Toolstrip Pin
Dave Kreskowiak31-Jul-11 5:24
mveDave Kreskowiak31-Jul-11 5:24 
GeneralRe: Font ComboBox add to Toolstrip Pin
nyt197231-Jul-11 19:36
professionalnyt197231-Jul-11 19:36 
GeneralRe: Font ComboBox add to Toolstrip Pin
Dave Kreskowiak1-Aug-11 4:49
mveDave Kreskowiak1-Aug-11 4:49 
GeneralRe: Font ComboBox add to Toolstrip Pin
nyt19722-Aug-11 2:42
professionalnyt19722-Aug-11 2:42 
GeneralRe: Font ComboBox add to Toolstrip Pin
Dave Kreskowiak2-Aug-11 4:47
mveDave Kreskowiak2-Aug-11 4:47 
GeneralRe: Font ComboBox add to Toolstrip Pin
nyt19722-Aug-11 22:21
professionalnyt19722-Aug-11 22:21 
QuestionConnection string in with sqlserver 2005 Pin
nazimghori31-Jul-11 1:30
nazimghori31-Jul-11 1:30 
AnswerRe: Connection string in with sqlserver 2005 Pin
Shameel31-Jul-11 1:53
professionalShameel31-Jul-11 1:53 
AnswerRe: Connection string in with sqlserver 2005 Pin
Eddy Vluggen31-Jul-11 3:56
professionalEddy Vluggen31-Jul-11 3:56 
AnswerRe: Connection string in with sqlserver 2005 Pin
Dave Kreskowiak31-Jul-11 5:18
mveDave Kreskowiak31-Jul-11 5:18 
GeneralRe: Connection string in with sqlserver 2005 [modified] Pin
nazimghori31-Jul-11 7:19
nazimghori31-Jul-11 7:19 
GeneralRe: Connection string in with sqlserver 2005 Pin
Dave Kreskowiak31-Jul-11 14:57
mveDave Kreskowiak31-Jul-11 14:57 
AnswerRe: Connection string in with sqlserver 2005 Pin
thatraja31-Jul-11 7:05
professionalthatraja31-Jul-11 7:05 
GeneralRe: Connection string in with sqlserver 2005 Pin
Shameel31-Jul-11 8:30
professionalShameel31-Jul-11 8:30 
GeneralRe: Connection string in with sqlserver 2005 Pin
thatraja31-Jul-11 16:37
professionalthatraja31-Jul-11 16:37 
QuestionUse MS Windows Theme Pin
ivo7530-Jul-11 22:14
ivo7530-Jul-11 22:14 
AnswerRe: Use MS Windows Theme Pin
Dalek Dave23-Aug-11 12:27
professionalDalek Dave23-Aug-11 12:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.