本文介绍了具有整数,双精度和十进制的TextBox.Databindings的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好, 我想将某些数据类型绑定到某些TextBoxes 这是我的代码,但是没有用.我必须要做的是代码正在运行?
hello all together, i would like to bind some datatypes to some TextBoxes here ist my code but it dosn`t work. what i have to do that the code is running?
class myContainer { protected double wall; protected decimal diameter; protected int ringcount; public double _wallthickness { get { return wall; } set { wall = value; } } public decimal _outerDiameter { get { return diameter; } set { diameter = value; } } public int _ringcount { get { return ringcount; } set { ringcount = value; } } } private void Form1_Load(object sender, EventArgs e) { myContainer container = new myContainer(); textBox1.DataBindings.Add("Text", container, "wall", true, DataSourceUpdateMode.OnPropertyChanged, string.Empty, "0.000"); textBox2.DataBindings.Add("Text", container, "diameter", true, DataSourceUpdateMode.OnPropertyChanged, string.Empty, "0.00"); textBox3.DataBindings.Add("Text", container, "ringcount", true, DataSourceUpdateMode.OnPropertyChanged, string.Empty, "0"); }
thanks for your help.
推荐答案您使用了错误的属性名称.像这样使用 textBox1.DataBindings.Add("Text",容器,"_wallthickness",true,DataSourceUpdateMode.OnPropertyChanged,string.Empty,"0.000"); You have used wrong property name. Use like this textBox1.DataBindings.Add("Text", container, "_wallthickness", true, DataSourceUpdateMode.OnPropertyChanged, string.Empty, "0.000");
更多推荐
具有整数,双精度和十进制的TextBox.Databindings
发布评论