C#列表框和标签预览 [英] C# listbox and label preview

查看:65
本文介绍了C#列表框和标签预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使标签始终显示列表框中的项目数,为此,我得到的全部是删除"按钮,该按钮删除所选项目,并添加一个项目.

I''m trying so that a label always shows the number of items in the listbox, all i got for this is remove button that removes the selected item and one that adds an item. how do i put these all together so that the label always shows the listbox''s item count?

推荐答案

private void btn_Add_Click(object sender, EventArgs e)
        {
        //Adding /////
     Label1.text = Convert.tostring(ListBox1.Items.Count);

     }


private void btn_Remove_Click(object sender, EventArgs e)
        {
        //Removing /////
     Label1.text = Convert.tostring(ListBox1.Items.Count);

     }


在添加按钮"事件中

Label1.text =";
添加/删除后

Label1.text = Convert.tostring(ListBox1.Items.Count);
On the Add Button event

Label1.text=" ";
after Adding / Removing

Label1.text = Convert.tostring(ListBox1.Items.Count);


这篇关于C#列表框和标签预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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