C# 数据绑定 未完

csharp 复制代码
List<int> integerList = new List<int> { 0 };
        BindingSource bs = new BindingSource();
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            bs.DataSource = integerList;
            label1.DataBindings.Add("Text", bs, "");
        }
        private void button1_Click(object sender, EventArgs e) {
            integerList[0]++;
            bs.ResetBindings(false);
        }

上述代码效果为点击ButtonLable的值++

需要注意一下几点

DataBindings.Add
相关推荐
xixingzhe213 小时前
MySQL CDC实现方案
数据库·mysql
tqs_1234513 小时前
tcc中的空回滚和悬挂问题
java·数据库
哪里不会点哪里.13 小时前
Spring 事务机制详解:原理、传播行为与失效场景
java·数据库·spring
EmbedLinX13 小时前
一文理解后端核心概念:同步/异步、阻塞/非阻塞、进程/线程/协程
linux·服务器·c语言·网络
小王努力学编程13 小时前
LangChain——AI应用开发框架(核心组件2)
linux·服务器·c++·人工智能·python·langchain·信号
IT大白14 小时前
8、MySQL相关问题补充
数据库·sql
爪哇天下14 小时前
Mysql实现经纬度距离的排序(粗略的城市排序)
数据库·mysql
独自破碎E14 小时前
MySQL中有哪些日志类型?
数据库·mysql
云服务器租用费用14 小时前
京东云主机企业用户能参与的优惠活动汇总
服务器·网络·京东云
笨蛋不要掉眼泪14 小时前
Redis核心数据类型与命令
数据库·redis·缓存