对,自己一个windows窗体的名字
解决方案 »
- 获取tabpage中的控件信息
- 二维数组排序问题,请教。
- 关于mshtml.HTMLLinkElement
- 在C#中,两个自定义控件,两个控件上都要提交到服务器端进行验证,怎样才能让一个控件提交时不影响到另一个自定义控件??? 急呀!!!
- 如何获得items中第一个item,在线等
- 用VS.NET2003创建项目中的XML文件怎么跑到别的目录中去了,疑惑?
- 如何截获webbrowser控件中flash发送的请求与服务器响应
- 一个很菜的问题!!
- 做一个项目的时候,上面的要求,请大家看看是否合理??
- C#调用Delphi写的dll的问题。
- .exe和.dll 文件如何存入SQL数据库image 类型
- 关于金质打印通左右边距和打印机横纵向的问题?(*)
-------------------------
出什么錯?貼出來.
正常情況f.ShowDialog()不可能需要用兩次
我时用了两个windows窗体,一个时form1,另一个是inputbox
这个时form1的代码:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 非模态对话框
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
InputBox f = new InputBox();//调用inputbox
f.ShowDialog();//问题在这里,为什么去掉这个就会错呢?后面if语句中不是有吗?
f.Title = "输入对话框";
f.TipText = "请输入年龄";
if (f.ShowDialog() == DialogResult.OK)
{
this.label1.Text = f.Message;
}
}
}
}
这个是inputbox的代码:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 非模态对话框
{
public partial class InputBox : Form
{
public InputBox()
{
InitializeComponent();
}
public string Title
{
set { this.Text = value; }
}
public string Message
{
get {return this.Input.Text;}
}
public string TipText
{
set { this.Tip.Text = value; }
} private void InputBox_Load(object sender, EventArgs e)
{
this.AcceptButton = this.btnOK;
this.CancelButton = this.btnCancel;
this.btnOK.DialogResult = DialogResult.OK;
this.btnCancel.DialogResult = DialogResult.Cancel;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ShowInTaskbar = false;
}
}
}
如果去掉我说的那段代码的话,就会出现这样的问题:当点form1上的按钮想启动inputbox时,inputbox只是在屏幕上闪一下就又关闭了!
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 非模态对话框
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
InputBox f = new InputBox();
//f.ShowDialog();
f.Title = "输入对话框";
f.TipText = "请输入年龄";
if (f.ShowDialog() == DialogResult.OK)
{
this.label1.Text = f.Message;
}
}
}
}using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 非模态对话框
{
public partial class InputBox : Form
{
public InputBox()
{
InitializeComponent();
}
public string Title
{
set { this.Text = value; }
}
public string Message
{
get {return this.Input.Text;}
}
public string TipText
{
set { this.Tip.Text = value; }
} private void InputBox_Load(object sender, EventArgs e)
{
this.AcceptButton = this.btnOK;
this.CancelButton = this.btnCancel;
this.btnOK.DialogResult = DialogResult.OK;
this.btnCancel.DialogResult = DialogResult.Cancel;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ShowInTaskbar = false;
}
}
}出现的问题是如果我把f.showdialog()这个语句去掉的话就会出现:当点击from1中的按钮启动inputbox时,inputbox只是闪了一下就又关闭了