如何通过从组合框中选择字体来更改动态创建的文本框的字体 [英] how to change font of dynamically created textbox by selecting font from combobox

查看:265
本文介绍了如何通过从组合框中选择字体来更改动态创建的文本框的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在点击特定按钮时创建多个文本框。

然后想要更改我从字体组合框中选择的文本框的字体。

解决方案

感谢大家的评价......我通过以下方式解决了我的问题。



 < span class =code-keyword>私有  Sub  btnBold_Click(发件人作为 对象,e 作为 EventArgs)
如果 btnBold.BackColor = Color.White 然后
对于 每个 c 作为控制 Me .pnlDesign.Controls
如果 TypeOf c TextBox AndAlso c.Name.ToString = txt& tNo 然后
c.Font = 字体(cboFont.Text,Convert.ToSingle(cboSize) .Text),FontStyle.bold)
结束 如果
下一步
btnBold.BackColor = Color.Aqua
否则
For 每个 c As Control .pnlDesign.Controls
如果 TypeOf c TextBox AndAlso c.Name.ToString = txt& tNo 然后
c.Font = 字体(cboFont.Text,Convert.ToSingle(cboSize) .Text),FontStyle.Regular)
结束 如果
下一步
btnBold.BackColor = Color.White
结束 如果
结束 Sub


I want to create multiple textboxes on clicking particular button.
And then want to change font of textbox which i have clicked on selecting from font combobox.

解决方案

thanks everybody for your valued comments...i have solved my problem by doing following.

Private Sub btnBold_Click(sender As Object, e As EventArgs)
    If btnBold.BackColor = Color.White Then
        For Each c As Control In Me.pnlDesign.Controls
            If TypeOf c Is TextBox AndAlso c.Name.ToString = "txt" & tNo Then
                c.Font = New Font(cboFont.Text, Convert.ToSingle(cboSize.Text), FontStyle.bold)
            End If
        Next
        btnBold.BackColor = Color.Aqua
    Else
        For Each c As Control In Me.pnlDesign.Controls
            If TypeOf c Is TextBox AndAlso c.Name.ToString = "txt" & tNo Then
                c.Font = New Font(cboFont.Text, Convert.ToSingle(cboSize.Text), FontStyle.Regular)
            End If
        Next
        btnBold.BackColor = Color.White
    End If
End Sub


这篇关于如何通过从组合框中选择字体来更改动态创建的文本框的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆