cs_seema
Messages postés9Date d'inscriptionlundi 16 août 2010StatutMembreDernière intervention 3 août 2011
-
17 oct. 2010 à 23:04
cs_seema
Messages postés9Date d'inscriptionlundi 16 août 2010StatutMembreDernière intervention 3 août 2011
-
18 oct. 2010 à 01:32
Salut ,
j'ai un petit problème et je veux votre aide svp les amis :'(
je suis débutant en VB.NET , et je veux réaliser un petit programme qui permet de changer la taille du texte écrit dans un textBox ( 8px , 12px , 18px ) , et aussi de changer le Style entre Gras et Italic ( deux CheckBox ) .
mon problème c'est que :
1) quand j'écris mon texte , et je coche la case Italic, après je coche la case Gras , je veux que mon texte soit en Gras et Italic en même temps
2) je vx changer la taille du texte quand je sélectionne une taille dans un ComboBox ( 8px , 12px , ou 18px ) ,
Voilà mon code :
Public Class Form1
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
'traitement pour les tailles 8px , 12px et 18px
'pour : 8px
Dim taille As Single
If ComboBox1.SelectedIndex = 0 Then
'taille = 8.0F
'TextBox1.Font = New Font(TextBox1.Font.Name, taille, Font.Style) sa marche pas , sa change la taille de la zone du texte et pas la taille du texte
End If
'pour : 12px
If ComboBox1.SelectedIndex = 1 Then
End If
'pour : 18px
If ComboBox1.SelectedIndex = 2 Then
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If (CheckBox1.Checked) Then
If Not TextBox1.Font.Bold Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Bold)
End If
Else
If TextBox1.Font.Bold Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Regular)
End If
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If (CheckBox2.Checked) Then
If Not TextBox1.Font.Italic Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Italic)
End If
Else
If TextBox1.Font.Italic Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Regular)
End If
End If
End Sub
End Class
Veuillez m'aider je vous en prie les amis
Merci bien :)
A voir également:
Police vscode
Ajouter police visual studio code - Meilleures réponses
Changer police visual studio code - Meilleures réponses
cs_ShayW
Messages postés3253Date d'inscriptionjeudi 26 novembre 2009StatutMembreDernière intervention 3 décembre 201957 18 oct. 2010 à 01:08
Bonsoir
(TextBox1.Font.Name, taille, Font.Style) sa marche pas , sa change la taille de la zone du texte et pas la taille du texte
je pense pas qu'on peut autrement
si tu aggrandis seulement le texte et non la zone
ton text va etre plus haut que le textbox
ce n'est possible que la taille tu text soit supérieur à la taille du textbox
il faut que le textbox envelloppe le text
tu as 2 checkbox un pour italic et un pour gras
donc j'ai 4 possibilitées
italic gras result
0 0 regular
0 1 gras
1 0 italic
1 1 gras et italic
Public Class Form5
Private Sub additem()
ComboBox1.Items.Add("taille 8")
ComboBox1.Items.Add("taille 12")
ComboBox1.Items.Add("taille 18")
'pour initier
TextBox1.Font = New Font("arial", 14, Font.Style, GraphicsUnit.Pixel)
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
'traitement pour les tailles 8px , 12px et 18px
'pour : 8px
Dim taille As Single
If ComboBox1.SelectedIndex = 0 Then
taille = 8
TextBox1.Font = New Font("arial", taille, Font.Style, GraphicsUnit.Pixel)
End If
'pour : 12px
If ComboBox1.SelectedIndex = 1 Then
taille = 12
TextBox1.Font = New Font("arial", taille, Font.Style, GraphicsUnit.Pixel)
End If
'pour : 18px
If ComboBox1.SelectedIndex = 2 Then
taille = 18
TextBox1.Font = New Font("arial", taille, Font.Style, GraphicsUnit.Pixel)
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged, CheckBox2.CheckedChanged
modify()
End Sub
Private Sub modify()
If CheckBox1.Checked False And CheckBox2.Checked False Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Regular)
End If
If CheckBox1.Checked False And CheckBox2.Checked True Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Italic)
End If
If CheckBox1.Checked True And CheckBox2.Checked False Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Bold)
End If
If CheckBox1.Checked True And CheckBox2.Checked True Then
TextBox1.Font = New Font(TextBox1.Font, FontStyle.Bold Or FontStyle.Italic)
End If
End Sub
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
modify()
End Sub
End Class