标签根据复选框(数组)而变化 [英] Label changes according to the checkboxes (arrays)

查看:70
本文介绍了标签根据复选框(数组)而变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

私有子Button13_Click(作为对象发送,作为EventArgs发送)处理Button13.Click
        Dim label()= {标签1,标签2,标签3,标签4,标签5,标签6,标签7,标签8,标签9,标签10}
        昏暗的checkbox()= {CheckBox1,CheckBox2,CheckBox3,CheckBox4,CheckBox5,CheckBox6,CheckBox7,CheckBox8,CheckBox9,CheckBox10}
        昏暗的整数
        对于i = 0到9
            如果复选框(i).
                Label21.Text = label(i).Text
            万一
        下一个
    结束

这是一个代码示例.选中数组中的复选框时,需要在Label21中显示标签的文本.

例如,当Checkbox1和Checkbox5检查,Label21需要显示label1和Label5的文本(与新线)

欢呼声,阿米娜

解决方案

那么,您需要像这样编辑代码:

 Label21.Text ="
        对于i = 0到9
            如果复选框(i).
                Label21.Text& = label(i).Text& " "
            万一
        下一个


我看不到您的标签中对换行符的兴趣吗?是多行吗?


Hi.

  Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        Dim label() = {Label1, Label2, Label3, Label4, Label5, Label6, Label7, Label8, Label9, Label10}
        Dim checkbox() = {CheckBox1, CheckBox2, CheckBox3, CheckBox4, CheckBox5, CheckBox6, CheckBox7, CheckBox8, CheckBox9, CheckBox10}
        Dim i As Integer
        For i = 0 To 9
            If checkbox(i).Checked Then
                Label21.Text = label(i).Text
            End If
        Next
    End Sub

Here is an example of a code. When checkbox that's in the array is checked, text of the label needs to be shown in the Label21. 

For example, when Checkbox1 and Checkbox5 are checked, Label21 needs to show texts of Label1 and Label5 (with New Line)

Cheers, Amina

解决方案

Well you need to edit your code like this:

        Label21.Text = ""
        For i = 0 To 9
            If checkbox(i).Checked Then
                Label21.Text &= label(i).Text & " "
            End If
        Next


I fail to see the interest of newline in your label? is it multiline somehow?


这篇关于标签根据复选框(数组)而变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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