更改蒙版文本框中的分隔符

Mar*_*tim 1 .net c# winforms

我正在尝试使用屏蔽文本框输入IP,并且数字当前正用逗号分隔.有没有办法用点字符替换逗号字符?

到目前为止,这是我屏蔽文本框的定义:

// 
// txtIPAddressForSaving
// 
this.txtIPAddressForSaving.Font = new System.Drawing.Font("Microsoft Sans Serif", 30F);
this.txtIPAddressForSaving.Location = new System.Drawing.Point(148, 115);
this.txtIPAddressForSaving.Mask = "009.009.009.009";
this.txtIPAddressForSaving.Name = "txtIPAddressForSaving";
this.txtIPAddressForSaving.PromptChar = '.';
this.txtIPAddressForSaving.Size = new System.Drawing.Size(463, 53);
this.txtIPAddressForSaving.TabIndex = 13;
this.txtIPAddressForSaving.TabStop = false;
Run Code Online (Sandbox Code Playgroud)

Kin*_*ing 7

试试这个:

this.txtIPAddressForSaving.Mask = @"009\.009\.009\.009";
Run Code Online (Sandbox Code Playgroud)

另一个选择是使用InvariantCulture你的MaskedTextBox(保持旧格式):

txtIPAddressForSaving.Mask = "009.009.009.009";
txtIPAddressForSaving.Culture = System.Globalization
                                      .CultureInfo.InvariantCulture;
Run Code Online (Sandbox Code Playgroud)

请注意,我们更改的文化仅适用于MaskedTextBox并且不应用任何其他控件.