Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di sanny82
    Registrato dal
    Mar 2003
    Messaggi
    689

    [Vb6] Cambiare font in textbox

    Ciao a tutti,
    ho un problema...

    Ho una textbox con all'interno una legenda.

    Questa legenda vorrei che contenga diversi font per ogni riga.

    Come posso fare?

    Ora mi prende solamente l'ultima riga che inserisco e con l'ultimo font che ho deciso di utilizzare...

    es.

    codice:
    Private Sub Form_Load()
    Text1.ForeColor = &H8000&
    Text1.FontBold = True
    Text1.Alignment = "2"
    Text1.Text = "Bloodlines Interactive Catalogue - Legend"
    pippo = Text1.Text
    Text1.ForeColor = &H8D520A
    Text1.FontBold = False
    Text1.Text = "ciccia" & "" & "This legend is an overview of the most frequently used components on our bloodlines."
    Text1.FontUnderline = True
    Text1.Alignment = "0"
    Text1.Text = "Arterial Pressure Pillows"
    Text1.Text = pippo & vbCrLf & vbCrLf & "This legend is an overview of the most frequently used components on our bloodlines."
    End Sub
    Grazie mille
    una parola è poca e due sono troppe

  2. #2
    Utente di HTML.it L'avatar di Brainjar
    Registrato dal
    Nov 2004
    Messaggi
    1,162
    Dovresti utilizzare un controllo RichTextBox al posto della normale
    TextBox.

    Per impostare i valori di una parte di testo, quest'ultima deve
    essere prima selezionata.

    Ti posto un esempio da MSDN (dove Text2 è il nome che hai dato al
    controllo) :
    codice:
    Private Sub Command4_Click()
         HighlightWords Text2, "width", vbRed
    End Sub
    
    Private Function HighlightWords(rtb As RichTextBox, _
                                   sFindString As String, _
                                   lColor As Long) _
                                   As Integer
    
         Dim lFoundPos As Long           'Position of first character of match
         Dim lFindLength As Long         'Length of string to find
         Dim lOriginalSelStart As Long
         Dim lOriginalSelLength As Long
         Dim iMatchCount As Integer      'Number of matches
    
         'Save the insertion points current location and length
         lOriginalSelStart = rtb.SelStart
         lOriginalSelLength = rtb.SelLength
    
         'Cache the length of the string to find
         lFindLength = Len(sFindString)
    
         'Attempt to find the first match
         lFoundPos = rtb.Find(sFindString, 0, , rtfNoHighlight)
         While lFoundPos > 0
           iMatchCount = iMatchCount + 1
    
           rtb.SelStart = lFoundPos
           'The SelLength property is set to 0 as
           'soon as you change SelStart
           rtb.SelLength = lFindLength
           rtb.SelColor = lColor
    
           'Attempt to find the next match
           lFoundPos = rtb.Find(sFindString, _
             lFoundPos + lFindLength, , rtfNoHighlight)
         Wend
    
         'Restore the insertion point to its original
         'location and length
         rtb.SelStart = lOriginalSelStart
         rtb.SelLength = lOriginalSelLength
    
         'Return the number of matches
         HighlightWords = iMatchCount
    
    End Function
    Ciao,
    Ciao, Brainjar

  3. #3
    Utente di HTML.it L'avatar di sanny82
    Registrato dal
    Mar 2003
    Messaggi
    689
    Scusa ma non ci capisco niente....

    Potresti farmi un esempio pratico?

    Grazie ancora
    una parola è poca e due sono troppe

  4. #4
    Utente di HTML.it L'avatar di Brainjar
    Registrato dal
    Nov 2004
    Messaggi
    1,162
    Eccoti l'esemipo :
    codice:
    ' Metti un controllo TichTextBox sul form al posto del tuo 
    ' controllo originale di tipo TextBox. Poniamo che lo chiami 
    ' Text2.
    Dim lOriginalSelStart As Long
    Dim lOriginalSelLength As Long
    Dim stringa1 As String
    Dim stringa2 As String
    Dim stringa3 As String
    
        stringa1 = "Bloodlines Interactive Catalogue - Legend"
        stringa2 = "This legend is an overview of the most frequently used components on our bloodlines."
        stringa3 = "This legend is an overview of the most frequently used components on our bloodlines."
        Text2.Text = stringa1 & vbCrLf & stringa2 & vbCrLf & stringa3
        lOriginalSelStart = 0
        lOriginalSelLength = Len(stringa1)
        
        Text2.SelStart = 0
        Text2.SelLength = lOriginalSelLength
        Text2.SelBold = True
        Text2.SelColor = &H8000&
        Text2.SelAlignment = rtfCenter
         
        lOriginalSelStart = Len(stringa1) + 2
        lOriginalSelLength = Len(stringa2)
        Text2.SelStart = lOriginalSelStart
        Text2.SelLength = lOriginalSelLength
        Text2.SelColor = &H8D520A
        Text2.SelBold = False
    
        lOriginalSelStart = Len(stringa1) + Len(stringa2) + 4
        lOriginalSelLength = Len(stringa3)
        Text2.SelStart = lOriginalSelStart
        Text2.SelLength = lOriginalSelLength
        Text2.SelColor = &H8D520A
        Text2.SelBold = False
        Text2.SelUnderline = True
    ciao,
    Ciao, Brainjar

  5. #5
    Utente di HTML.it L'avatar di sanny82
    Registrato dal
    Mar 2003
    Messaggi
    689
    Ora è tutto chiaro.

    Grazie mille per l'aiuto.
    una parola è poca e due sono troppe

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.