您可以在这里快速查找:


 
您的位置: 编程学习 > asp.net教程 > 200509
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

如何不使用可视化设计来显示登陆窗体?

bineon

在论坛看到这个帖子,觉得有意思,就实现了一下。其实这个问题以前的高人写了文章的。好像是net_lover吧,记的不是很清楚。

代码如下:

using System;
using System.Windows.Forms;
class test
{
 Form frm = new Form();
 Button btnOK = new Button();
 TextBox txtPsw = new TextBox();
 
 static void Main(string [] args)
 {
  test temp = new test();
  temp.showFrm();
  //Console.ReadLine();
 }
 
 private void showFrm()
 {
  btnOK.Text = "确定";
  frm.Text = "登陆";
  txtPsw.Location = new System.Drawing.Point(10,10);
  btnOK.Location = new System.Drawing.Point(txtPsw.Left,txtPsw.Top + txtPsw.Height + 10);
  btnOK.Click += new System.EventHandler(btnOKClick);
  frm.FormBorderStyle = FormBorderStyle.FixedDialog;
  frm.Controls.Add(txtPsw);
  frm.Controls.Add(btnOK);
  frm.StartPosition = FormStartPosition.CenterScreen;
  frm.ShowDialog();
 }
 
 private void btnOKClick(object sender, System.EventArgs e)
 {
  //验证信息
  MessageBox.Show(txtPsw.Text);
 }
}