更改分隔符的蒙面文本 [英] Changing the separator character in a masked textbox

查看:149
本文介绍了更改分隔符的蒙面文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个蒙面的文本框输入一个IP和数字目前正在用逗号分隔。有没有什么办法与点字符替换逗号?

这是我的蒙面文本框的定义至今:

  //
// txtIPAddressForSaving
//
this.txtIPAddressForSaving.Font =新System.Drawing.Font(Microsoft无衬线,30F);
this.txtIPAddressForSaving.Location =新System.Drawing.Point(148,115);
this.txtIPAddressForSaving.Mask =009.009.009.009;
this.txtIPAddressForSaving.Name =txtIPAddressForSaving;
this.txtIPAddressForSaving.PromptChar ='。';
this.txtIPAddressForSaving.Size =新System.Drawing.Size(463,53);
this.txtIPAddressForSaving.TabIndex = 13;
this.txtIPAddressForSaving.TabStop = FALSE;
 

解决方案

试试这个:

  this.txtIPAddressForSaving.Mask = @009 \ 0.009 \ 0.009 \ 0.009;
 

另一种选择是使用 InvariantCulture的的MaskedTextBox (保留旧的格式):

  txtIPAddressForSaving.Mask =009.009.009.009;
txtIPAddressForSaving.Culture = System.Globalization
                                      .CultureInfo.InvariantCulture;
 

需要注意的是,我们改变了文化的的MaskedTextBox 只适用与不适用任何其他控件。

I'm attempting to use a masked textbox to input an IP and the digits are currently being separated by a comma. Is there any way to replace the comma character with the dot character?

This is the definition of my masked textbox so far:

// 
// 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;

解决方案

Try this:

this.txtIPAddressForSaving.Mask = @"009\.009\.009\.009";

Another option is to use InvariantCulture for your MaskedTextBox (keep the old format):

txtIPAddressForSaving.Mask = "009.009.009.009";
txtIPAddressForSaving.Culture = System.Globalization
                                      .CultureInfo.InvariantCulture;

Note that, the culture we change is applied only for the MaskedTextBox and doesn't apply any other controls.

这篇关于更改分隔符的蒙面文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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