vb 程序题,大家帮忙啊
组合框中有下拉列表,上面有“黑体。宋体。等”,如何编程使我点击黑体时text1中的字体可以变成黑体,宋体也是这个路子。哥们只需要帮我写一下主要程序就行了。我就是不知道怎么...
组合框中有下拉列表,上面有“黑体。宋体。等”,如何编程使我点击黑体时text1中的字体可以变成黑体,宋体也是这个路子。哥们只需要帮我写一下主要程序就行了。我就是不知道怎么调用
展开
2个回答
展开全部
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'用连个Combobox添加两个新项
cmb.Items.Clear()
cmb.Items.Add("黑体")
cmb.Items.Add("宋体")
End Sub
Private Sub cmb_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb.SelectedIndexChanged
txt.Text = cmb.Items(cmb.SelectedIndex)
'新定义文本的字体,字号,字体风格
txt.Font = New Font(txt.Text, 14, FontStyle.Regular)
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'用连个Combobox添加两个新项
cmb.Items.Clear()
cmb.Items.Add("黑体")
cmb.Items.Add("宋体")
End Sub
Private Sub cmb_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmb.SelectedIndexChanged
txt.Text = cmb.Items(cmb.SelectedIndex)
'新定义文本的字体,字号,字体风格
txt.Font = New Font(txt.Text, 14, FontStyle.Regular)
End Sub
End Class
展开全部
Private Sub Combo1_click()
If Combo1.Text = "黑体" Then Text1.Font = "黑体"
End Sub
Private Sub Form_Load()
Combo1.AddItem "黑体"
End Sub
If Combo1.Text = "黑体" Then Text1.Font = "黑体"
End Sub
Private Sub Form_Load()
Combo1.AddItem "黑体"
End Sub
追问
我想知道的是在combo1的list中有两个值“宋体”和“黑体”,我希望我点击宋体的时候text1可以变成宋体,点黑体的时候text2变成黑体
追答
Private Sub Combo1_click()
If Combo1.Text = "黑体" Then Text1.Font = "黑体"
If Combo1.Text = "宋体" Then Text1.Font = "宋体"
End Sub
Private Sub Form_Load()
Combo1.AddItem "黑体"
Combo1.AddItem "宋体"
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询