VB.Net - Yazı tiplerini, renkleri ve kontrol stilini değiştirin
![](http://img.brin-designs.com/img/games/513/vb-net-change-fonts.png)
giriş
Her zamanki gibi VB.Net bir kontrolün yazı tipi değiştirildiğinde garip tepkilere sahip olduğu için stiller sıfırlanır ve yeniden tanımlanmaları gerekir.
Bu sorunu ele almak için:
Kod
Genel Sınıf Form1 Özel Alt Form1_Load (System.Object, ByVal e System.EventArgs Olarak ByVal gönderen) MyBase.Load Boyutunu Bayt, L, S olarak Tamsayı Olarak Ayarla FonteSys FontFamily TextBox1.Text = " pot et que ça sonne creux, en çok tercih edilenler arasında en iyisidir.; -) (Konfüçyüs) "S = TextBox1.Font.Size için i = 8 - 24 Adım 2 ComboBox1.Items.Add (i) = S Sonra L = ComboBox1.Items.Count - 1 Sonraki ComboBox1.SelectedIndex'ı deneyin = L İstisna Olarak Eşle ComboBox1.SelectedIndex = ComboBox1.Items.Count - 1 Sonu Denemesi 'Propriétés de la boite de dialogue couleur' BoiteCouleur.SolidColorOly 'Couleurs birlik' BoiteCouleur.AllowFullOpen = Doğru 'Affiche le bouton des couleurs personnalisées' BoiteCouleur.FullOpen = Gerçek 'Affiche les couleurs personnalisées' BoiteCouleur.Color = Color.Red ' Aileler CombPolice.Items.Add (FonteSys.Name) TextBox1.Font.Name = FonteSys.Name Sonra L = CombPolice.Ite ms.Count - 1 Sonraki Deneyin CombPolice.SelectedIndex = L İstisnai Durum Olarak Yakalayın ex ComboBox1.SelectedIndex = 0 Sonu Dene Alt Özel Alt ComboBox1_SelectedIndexChanged (System.Object Olarak ByVal gönderen) System.Object Olarak InVal e.Sistem.EventArgs Olarak Gönderildi) ComboBox1.Sel Olarak Değiştirildi Font = TextBox1.Font Dim newFont As Font = Yeni Font (oldFont.FontFamily, Val (ComboBox1.Text)) TextBox1.Font = newFont ChangeStyle () Alt Özel Alt CheckBox1_CheckedChanged_1 (System.Object, ByVal e Sistem Olarak Alt Gönderen). EventArgs) CheckBox1.CheckedChanged, _ CheckBox2.CheckedChanged, CheckBox3.CheckedChanged, CheckBox4.CheckedChanged ChangeStyle () 'Autre sözdizimi' DimStyle olarak FontStyle = IIf (TextBox1.Font.Style ve FontStyle.BoldFil.Fil.Fil.Fil.tr. .Bold, TextBox1.Font.Style Veya FontStyle.Bold) 'TextBox1.Font = Yeni Yazı Tipi (TextBox1.Font, style) End Alt Özel Alt Button1_Click (System.Object Olarak ByVal gönderen, System.EventArgs Olarak ByVal e) Button1'i işler. Tıklayın BoiteCouleur.ShowDialog () = Di alogResult.OK Sonra TextBox1.ForeColor = BoiteCouleur.Color 'Autre sözdizimi' TextBox1.ForeColor = Color.FromArgb (& HFF0000) Sonunda Alt Özel Alt Button2_Click (System.Object Olarak System_Offject, System_Off_Eğreleri_Bağlantılar_Bağla). Tıklayın BoiteCouleur.ShowDialog () = DialogResult.OK Sonra TextBox1.BackColor = BoiteCouleur.Color Sonunda Alt Özel Alt CombPolice_SelectedIndexChanged Sonunda (System.Object Olarak ByVal gönderen, System.EventArgs Olarak ByVal Gönderen). Ad CombPolice.Text Sonra TextBox1.Font = Yeni System.Drawing.Font (CombPolice.Text, CInt (ComboBox1.Text)) ChangeStyle () Son Alt Altsa Sona Dönükledilir. Veya FontStyle.Italic Ve CheckBox2.Checked _ Veya FontStyle.Underline Ve CheckBox3.Checked Veya FontStyle.Strikeout Ve _ CheckBox4.Checked 'Pas de chae fois. 'TextBox1.Font = Yeni Sistem.Drawing.Font (CombPolice.Text, CInt (ComboBox1.Text)) TextBox1.Font = Yeni Yazı Tipi (TextBox1.Font, stil) End Sub End Sınıfı
İndir
Demo çözümünü indirin
Sunucu 1: burada