如何用C#编一个IP地址输入框??? 如何用C#编一个IP地址输入框???效果就像我们现在电脑上用的"网络连接"中的IP地址输入框一样 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 加条件来限制. 用四个TextBox, 然后用程序来处理,加条件.. MaskBox,不行就4个textBox加事件=============================== msn:[email protected] 重写TextBox,里面初始化...个点,然后做KeyDoum些判断了! 上www.codeproject.com上面有一个开放源码的例子你可以Down下来看看 www.codeproject.com英文网站一点都看不懂看晕头了有没有中文的 http://www.codeproject.com/useritems/IPTextBox.asp 我早就散过分了。http://community.csdn.net/Expert/topic/4231/4231425.xml 有正则表达示对TEXTBOX做限制就行了正则表达示:^((1??\d{1,2}|2[0-4]\d|25[0-5])\.){3}(1??\d{1,2}|2[0-4]\d|25[0-5])$如果你输入的不是正确的IP地址,就会提示错误 <!--运行以下程序,在IP地址输入框中输入333试试?--><html xmlns:v="urn:schemas-microsoft-com:vml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title>IP-like Input</title><style><!--v\:* { behavior: url(#default#VML) }div.IPDiv { background: #FFFFFF; width: 120; margin:0; font-family: Arial,Tahoma; font-size: 10pt; text-align: center; border-top: 2 ridge threedshadow; border-left: 2 ridge threedshadow; border-right: 2 inset threedhighlight; border-bottom: 2 inset threedhighlight }input.IPInput { width: 24; margin:0; font-family: Arial,Tahoma; font-size: 10pt; text-align: center; border-width: 0 }--></style></head><body bgcolor=threedface><div id="alertInfoDiv" style="position: absolute; left:100; top:40; display:none"> <v:roundrect strokecolor="black" fillcolor="infobackground" style="position:relative;left:30;top:5;width:130px;height:40px;z-index:9"> <v:shadow on="t" type="single" color="silver" offset="3pt,-3pt"></v:shadow> <v:textbox id="alertInfo" style="font-family:Arial,Tahoma;font-size:10pt;color:infotext;line-height:18px" inset="2px,2px,2px,2px"></v:textbox> </v:roundrect> <v:oval strokecolor="black" fillcolor="infobackground" style="position:relative;left:-120;top:20;width:14px;height:10px;z-index:8"> <v:shadow on="t" type="single" color="silver" offset="3pt,-3pt"></v:shadow> </v:oval> <v:oval strokecolor="black" fillcolor="infobackground" style="position:relative;left:-160;top:32;width:10px;height:8px;Z-index:7"> <v:shadow on="t" type="single" color="silver" offset="3pt,-3pt"></v:shadow> </v:oval> </div>IP地址输入栏: <div style="position: absolute; left: 50; top:115; text-align: center; vertical-align: middle;"> <script> IPlikeInputStr = ""; IPlikeInputStr += '<div class="IPDiv">'; for (i=0;i<4;i++) { IPlikeInputStr += '<input class="IPInput" name="IPInput'+i+'" type="text" size="3" maxlength="3" onkeypress="keyHandle()" onkeyup="checkInput()">'+((i==3) ? '' : '.'); } IPlikeInputStr += '</div>'; document.write(IPlikeInputStr); function keyHandle() { if (event.keyCode<48||event.keyCode>57) { event.returnValue = false; } } function checkInput() { if (event.srcElement.name=="IPInput0") { if (event.srcElement.value==0&&event.srcElement.value.length==3) { event.srcElement.value="1"; VMLAlert("请输入一个界于1和223之间的数值。",67); //alert("请输入一个界于1和223之间的数值。"); event.srcElement.select(); } if (event.srcElement.value>223) { event.srcElement.value="223"; VMLAlert("请输入一个界于1和223之间的数值。",67); //alert("请输入一个界于1和223之间的数值。"); event.srcElement.select(); } } else { if (event.srcElement.value>255) { event.srcElement.value="255"; var theSrcName = event.srcElement.name; var theAlertPos = theSrcName=="IPInput1" ? 95 : (theSrcName=="IPInput2" ? 122 :150); VMLAlert("请输入一个界于0和255之间的数值。",theAlertPos); //alert("请输入一个界于0和255之间的数值。") event.srcElement.select(); } } } function VMLAlert(alertText,alertPos) { with (document.all) { alertInfo.innerHTML = alertText; alertInfoDiv.style.left = alertPos; alertInfoDiv.style.display = ""; } setTimeout('document.all.alertInfoDiv.style.display = "none"',3000);} </script> </div> </body> </html> 不好意思我要的是在WinForm下实现的 重复继承? 请问,ClickOnce可以部署到linux服务器上么? 事件相关 c# forms中的一个结构和类在Forms实现时提示错误的问题 点击X不能恢复到调试前的状态? 影片中音频部分Alignment : Split accross interleaves什么意思? comBoxEx dev控件,关于下拉框可编辑的问题 DataSet.table[0].select问题 刚建了个.Net爱好者的QQ群,欢迎大家加入:9179108 关于winform的问题-----------------求关注 用短信猫的比较难问题 关于字符串比较大小问题,在线等!
msn:[email protected]
你可以Down下来看看
英文网站
一点都看不懂
看晕头了
有没有中文的
http://community.csdn.net/Expert/topic/4231/4231425.xml
<html xmlns:v="urn:schemas-microsoft-com:vml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>IP-like Input</title>
<style>
<!--
v\:* { behavior: url(#default#VML) }
div.IPDiv { background: #FFFFFF; width: 120; margin:0; font-family: Arial,Tahoma; font-size: 10pt; text-align: center; border-top: 2 ridge threedshadow; border-left: 2 ridge threedshadow; border-right: 2 inset threedhighlight; border-bottom: 2 inset threedhighlight }
input.IPInput { width: 24; margin:0; font-family: Arial,Tahoma; font-size: 10pt; text-align: center; border-width: 0 }-->
</style>
</head><body bgcolor=threedface>
<div id="alertInfoDiv" style="position: absolute; left:100; top:40; display:none">
<v:roundrect strokecolor="black" fillcolor="infobackground" style="position:relative;left:30;top:5;width:130px;height:40px;z-index:9">
<v:shadow on="t" type="single" color="silver" offset="3pt,-3pt"></v:shadow>
<v:textbox id="alertInfo" style="font-family:Arial,Tahoma;font-size:10pt;color:infotext;line-height:18px" inset="2px,2px,2px,2px"></v:textbox>
</v:roundrect>
<v:oval strokecolor="black" fillcolor="infobackground" style="position:relative;left:-120;top:20;width:14px;height:10px;z-index:8">
<v:shadow on="t" type="single" color="silver" offset="3pt,-3pt"></v:shadow>
</v:oval>
<v:oval strokecolor="black" fillcolor="infobackground" style="position:relative;left:-160;top:32;width:10px;height:8px;Z-index:7">
<v:shadow on="t" type="single" color="silver" offset="3pt,-3pt"></v:shadow>
</v:oval>
</div>
IP地址输入栏:
<div style="position: absolute; left: 50; top:115; text-align: center; vertical-align: middle;">
<script>
IPlikeInputStr = "";
IPlikeInputStr += '<div class="IPDiv">';
for (i=0;i<4;i++) {
IPlikeInputStr += '<input class="IPInput" name="IPInput'+i+'" type="text" size="3" maxlength="3" onkeypress="keyHandle()" onkeyup="checkInput()">'+((i==3) ? '' : '.');
}
IPlikeInputStr += '</div>';
document.write(IPlikeInputStr);
function keyHandle() {
if (event.keyCode<48||event.keyCode>57) {
event.returnValue = false;
}
}
function checkInput() {
if (event.srcElement.name=="IPInput0") {
if (event.srcElement.value==0&&event.srcElement.value.length==3) {
event.srcElement.value="1";
VMLAlert("请输入一个界于1和223之间的数值。",67);
//alert("请输入一个界于1和223之间的数值。");
event.srcElement.select();
}
if (event.srcElement.value>223) {
event.srcElement.value="223";
VMLAlert("请输入一个界于1和223之间的数值。",67);
//alert("请输入一个界于1和223之间的数值。");
event.srcElement.select();
}
}
else {
if (event.srcElement.value>255) {
event.srcElement.value="255";
var theSrcName = event.srcElement.name;
var theAlertPos = theSrcName=="IPInput1" ? 95 : (theSrcName=="IPInput2" ? 122 :150);
VMLAlert("请输入一个界于0和255之间的数值。",theAlertPos);
//alert("请输入一个界于0和255之间的数值。")
event.srcElement.select();
}
}
} function VMLAlert(alertText,alertPos) {
with (document.all) {
alertInfo.innerHTML = alertText;
alertInfoDiv.style.left = alertPos;
alertInfoDiv.style.display = "";
}
setTimeout('document.all.alertInfoDiv.style.display = "none"',3000);}
</script>
</div>
</body>
</html>
我要的是在WinForm下实现的