NumericUpDown c#

本文关键字:NumericUpDown | 更新日期: 2023-09-27 17:57:56

NumericUpDown控件有问题。

在winForm代码中:

this.passwordLength = new NumericUpDown();
this.passwordLength.Location = new System.Drawing.Point(304, 11);
this.passwordLength.Margin = new System.Windows.Forms.Padding(2);
this.passwordLength.Maximum = new decimal(new int[] {128,0,0,0});
this.passwordLength.Minimum = new decimal(new int[] {1,0,0,0});
this.passwordLength.Name = "passwordLength";
this.passwordLength.Size = new System.Drawing.Size(41, 20);
this.passwordLength.TabIndex = 2;
this.passwordLength.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.passwordLength.Value = new decimal(new int[] {12,0,0,0});
this.passwordLength.ReadOnly = false;

最后一个"ReadOnly"属性应该允许客户端手动输入值,而不仅仅是通过箭头键或单击文本框旁的箭头,我说得对吗?

这正是我想要的。但它不适用于上面的代码。如果根本没有提到ReadOnly,那么通过写入文本框进行编辑是不可能的,目标是使其成为可能!

感谢

NumericUpDown c#

ReadOnly使它无法与它交互。你查看过你的默认属性吗。右键单击数字。

如果没有,请尝试删除它并创建一个新的数字。然后复制并粘贴代码。

因为它对我有效。

ReadOnly确实是一个属性,用于定义是否可以手动输入值,或者仅使用按钮输入值。代码应该可以工作,所以我认为问题出在其他地方