您的位置:首页 > 编程语言 > Delphi

.net C# inputBox文字输入对话框,类似delphi的inputBox收藏

2008-09-12 22:30 417 查看
private string InputBox(string Caption, string Hint, string Default)




...{


//by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2007.10.10


Form InputForm = new Form();


InputForm.MinimizeBox = false;


InputForm.MaximizeBox = false;


InputForm.StartPosition = FormStartPosition.CenterScreen;


InputForm.Width = 220;


InputForm.Height = 150;


//InputForm.Font.Name = "宋体";


//InputForm.Font.Size = 10;




InputForm.Text = Caption;


Label lbl = new Label();


lbl.Text = Hint;


lbl.Left = 10;


lbl.Top = 20;


lbl.Parent = InputForm;


lbl.AutoSize = true;


TextBox tb = new TextBox();


tb.Left = 30;


tb.Top = 45;


tb.Width = 160;


tb.Parent = InputForm;


tb.Text = Default;


tb.SelectAll();


Button btnok = new Button();


btnok.Left = 30;


btnok.Top = 80;


btnok.Parent = InputForm;


btnok.Text = "确定";


InputForm.AcceptButton = btnok;//回车响应




btnok.DialogResult = DialogResult.OK;


Button btncancal = new Button();


btncancal.Left = 120;


btncancal.Top = 80;


btncancal.Parent = InputForm;


btncancal.Text = "取消";


btncancal.DialogResult = DialogResult.Cancel;


try




...{


if (InputForm.ShowDialog() == DialogResult.OK)




...{


return tb.Text;


}


else




...{


return null;


}


}


finally




...{


InputForm.Dispose();


}




}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐