Click here to Skip to main content
16,005,222 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionresizing form with a RTB inside Pin
hang_em2-Aug-11 23:58
hang_em2-Aug-11 23:58 
AnswerRe: resizing form with a RTB inside Pin
Dave Kreskowiak3-Aug-11 2:05
mveDave Kreskowiak3-Aug-11 2:05 
GeneralRe: resizing form with a RTB inside Pin
hang_em3-Aug-11 18:01
hang_em3-Aug-11 18:01 
GeneralRe: resizing form with a RTB inside Pin
Dave Kreskowiak3-Aug-11 18:39
mveDave Kreskowiak3-Aug-11 18:39 
GeneralRe: resizing form with a RTB inside Pin
hang_em4-Aug-11 3:24
hang_em4-Aug-11 3:24 
GeneralRe: resizing form with a RTB inside Pin
Dave Kreskowiak4-Aug-11 13:55
mveDave Kreskowiak4-Aug-11 13:55 
QuestionCallbackOnCollectedDelegate was detected with LowLevelMouserProc Pin
Member 78319591-Aug-11 11:46
Member 78319591-Aug-11 11:46 
QuestionFont ComboBox add to Toolstrip Pin
nyt197231-Jul-11 3:13
professionalnyt197231-Jul-11 3: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 4:24
mveDave Kreskowiak31-Jul-11 4:24 
GeneralRe: Font ComboBox add to Toolstrip Pin
nyt197231-Jul-11 18:36
professionalnyt197231-Jul-11 18:36 
GeneralRe: Font ComboBox add to Toolstrip Pin
Dave Kreskowiak1-Aug-11 3:49
mveDave Kreskowiak1-Aug-11 3:49 
GeneralRe: Font ComboBox add to Toolstrip Pin
nyt19722-Aug-11 1:42
professionalnyt19722-Aug-11 1:42 
GeneralRe: Font ComboBox add to Toolstrip Pin
Dave Kreskowiak2-Aug-11 3:47
mveDave Kreskowiak2-Aug-11 3:47 
GeneralRe: Font ComboBox add to Toolstrip Pin
nyt19722-Aug-11 21:21
professionalnyt19722-Aug-11 21:21 
QuestionConnection string in with sqlserver 2005 Pin
nazimghori31-Jul-11 0:30
nazimghori31-Jul-11 0:30 
AnswerRe: Connection string in with sqlserver 2005 Pin
Shameel31-Jul-11 0:53
professionalShameel31-Jul-11 0:53 
AnswerRe: Connection string in with sqlserver 2005 Pin
Eddy Vluggen31-Jul-11 2:56
professionalEddy Vluggen31-Jul-11 2:56 
AnswerRe: Connection string in with sqlserver 2005 Pin
Dave Kreskowiak31-Jul-11 4:18
mveDave Kreskowiak31-Jul-11 4:18 
GeneralRe: Connection string in with sqlserver 2005 [modified] Pin
nazimghori31-Jul-11 6:19
nazimghori31-Jul-11 6:19 
GeneralRe: Connection string in with sqlserver 2005 Pin
Dave Kreskowiak31-Jul-11 13:57
mveDave Kreskowiak31-Jul-11 13:57 
AnswerRe: Connection string in with sqlserver 2005 Pin
thatraja31-Jul-11 6:05
professionalthatraja31-Jul-11 6:05 
GeneralRe: Connection string in with sqlserver 2005 Pin
Shameel31-Jul-11 7:30
professionalShameel31-Jul-11 7:30 
GeneralRe: Connection string in with sqlserver 2005 Pin
thatraja31-Jul-11 15:37
professionalthatraja31-Jul-11 15:37 
QuestionUse MS Windows Theme Pin
ivo7530-Jul-11 21:14
ivo7530-Jul-11 21:14 
AnswerRe: Use MS Windows Theme Pin
Dalek Dave23-Aug-11 11:27
professionalDalek Dave23-Aug-11 11: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.