السلام عليكم ورحمة الله وبركاته
اخوتي الكرام في المنتدى
لدي textbox فيه نص يمكنني عمله bold او italic او underline كل على حدة بالكود المرفق
والسؤال هو كيف يمكنني تطبيق bold و italic معا او bold و italic و underline معا
وجزاكم الله خير جزاء
كود :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyFontStyle As FontStyle
MyFontStyle = FontStyle.Regular
If ChkBox_Bold.Checked Then
MyFontStyle = FontStyle.Bold
End If
If ChkBox_Italic.Checked Then
MyFontStyle = FontStyle.Italic
End If
If ChkBox_UnderLine.Checked Then
MyFontStyle = FontStyle.Underline
End If
TextBox1.Font = New Font(TextBox1.Font.FontFamily, TextBox1.Font.Size, MyFontStyle)
End Sub
السلام عليكم ورحمة الله وبركاته
لاغنى عن منتدانا الغالي ولاعن المساعدة من اخوتنا الاعضاء الأعزاء
الحمد لله الذي وفقني بكتابة الكود لما أريد وهذا هو الكود الجديد ارفقه ليستفيد منه الجميع ودمتم بخير
كود :
Private Sub ChkBox_Bold_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChkBox_Bold.CheckedChanged
If ChkBox_Bold.Checked Then
TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style Or FontStyle.Bold)
Else
TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style And Not FontStyle.Bold)
End If
End Sub
Private Sub ChkBox_Italic_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChkBox_Italic.CheckedChanged
If ChkBox_Italic.Checked Then
TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style Or FontStyle.Italic)
Else
TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style And Not FontStyle.Italic)
End If
End Sub
Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChkBox_UnderLine.CheckedChanged
If ChkBox_UnderLine.Checked Then
TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style Or FontStyle.Underline)
Else
TextBox1.Font = New Font(TextBox1.Font, TextBox1.Font.Style And Not FontStyle.Underline)
End If
End Sub