chloe 调教 NEWS
你的位置:射人阁 > chloe 调教 > 裸舞 推特 Winform中使用MaskedTextBox制作IP地址输入框
裸舞 推特 Winform中使用MaskedTextBox制作IP地址输入框
发布日期:2025-07-03 06:02    点击次数:132

裸舞 推特 Winform中使用MaskedTextBox制作IP地址输入框

环境:C/S Winform C#裸舞 推特

Demo:

图片

功能:自动开垦ip掩码,输入形如999.999.999.999的表情,并开垦keydown事件,当输入.的技艺,自动跳至下一栏。

才调:

1,从器用箱中拖入一个MaskedTextBox,定名为txtPACSIP;

2,在mask属性中,输入:999.999.999.999

情色社区

3,在prompt属性中,将_换为空格。若是你可爱_的话,也不错无谓换。

4,创建KeyDown事件,附以下代码:

private void txtPACSIP_KeyDown(object sender, KeyEventArgs e)
 {
  if (e.KeyCode == Keys.Decimal)
  {
   int pos = txtPACSIP.SelectionStart;
   int max = (txtPACSIP.MaskedTextProvider.Length - txtPACSIP.MaskedTextProvider.EditPositionCount);
   int nextField = 0;
 
   for (int i = 0; i < txtPACSIP.MaskedTextProvider.Length; i++)
   {
 if (!txtPACSIP.MaskedTextProvider.IsEditPosition(i) && (pos + max) >= i)
  nextField = i;
   }
   nextField += 1;
 
   // We're done, enable the TabStop property again   
 
 
   txtPACSIP.SelectionStart = nextField;
 
  }
 }

虽然, 你若是思将tab键也杀青自动跳至下一栏的话,多加个要求就行。

5,在取值的经过中,记起要replace空格:

PingReply reply = p1.Send(this.txtPACSIP.Text.Replace(" ",""));

本站仅提供存储工作,通盘本体均由用户发布,如发现存害或侵权本体,请点击举报。