送分小问题一个!

esimer 2004-06-22 10:25:04
C#里面有没有那种对话框式的输入窗口。
例如:我想按一个按钮弹出一个类似MessageBox的小窗体,这个窗体只有一个输入框和一个确定按钮,填入数字点击确定按钮以后就关闭了。
填入的这个数字需要验证。
不知道C#里面有没有完成类似功能的现成的类,MessageBox能完成这个功能吗?
...全文
138 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzg530 2004-06-22
  • 打赏
  • 举报
回复
自己怎么写,给出个标准答案,
初学c#
qingyun1020 2004-06-22
  • 打赏
  • 举报
回复
接分,自己写吧
yqhi 2004-06-22
  • 打赏
  • 举报
回复
为什么要实现这样的功能呢?
Firestone2003 2004-06-22
  • 打赏
  • 举报
回复
很easy的东西
自己写
usxue 2004-06-22
  • 打赏
  • 举报
回复
自己写一个就行了
daguzhang 2004-06-22
  • 打赏
  • 举报
回复
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace alert
{
/// <summary>
/// alert 的摘要说明。
/// </summary>
public class alert : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public alert()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(40, 24);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(192, 24);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// alert
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 85);
this.ControlBox = false;
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "alert";
this.Text = "alert";
this.ResumeLayout(false);

}
#endregion

private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if ( e.KeyChar > (char)47 && e.KeyChar < (char)58 || e.KeyChar ==(char)8 ||e.KeyChar==(char)46)
{
e.Handled = false;
}
else
{
e.Handled = true;
MessageBox.Show("请输入数字");
}
}

private void button1_Click(object sender, System.EventArgs e)
{
if(this.textBox1.Text!="")
this.Close();
}

private void textBox1_TextChanged(object sender, System.EventArgs e)
{

}
}
}



调用它:
using alert;
private void button1_Click(object sender, System.EventArgs e)
{
alert Alert=new alert();
Alert.ShowDialog();

}
chrovan 2004-06-22
  • 打赏
  • 举报
回复
用winform自己写一个吧
jiezhi 2004-06-22
  • 打赏
  • 举报
回复
自己写
daguzhang 2004-06-22
  • 打赏
  • 举报
回复
不能 你自己写一个吧
hikecn 2004-06-22
  • 打赏
  • 举报
回复
自己用winform写拉!
dulkernetbug 2004-06-22
  • 打赏
  • 举报
回复
对,自己写一个页面也行啊,
lwjlwj 2004-06-22
  • 打赏
  • 举报
回复
自己写,模仿输入框用winform做一个
xuguchu 2004-06-22
  • 打赏
  • 举报
回复
不對,是
myform.show();
誤操作
xuguchu 2004-06-22
  • 打赏
  • 举报
回复
在你的按鈕里面打開你設計的窗體(如form2)吧
事件代碼:
form2 myform=new from2();
myform2.show();
在你的form2窗體(實質上是個類)上放一個text控件,和一個,button.
在button的事件中定返回你的text不就成了嗎
zhpsam109 2004-06-22
  • 打赏
  • 举报
回复
自己用winform设计并写代码阿!

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧