最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
C#里的InputBox
时间:2022-07-02 11:05:12 编辑:袖梨 来源:一聚教程网
在.NET Framework中并没有类似VB中的InputBox函数,虽然可以借助对VB 的Runtime引用,以在VB除外的.NET程序中使用VB的InputBox,但是为什么不自己写一个类实现类似的功能呢?
下面一个类实现了类似的InputBox函数的功能:
using System;
using System.Windows.Forms;
namespace Input
{
///
/// clsInputBox 的摘要说明。
///
public class InputBox : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtData;
private System.Windows.Forms.Label lblInfo;
private System.ComponentModel.Container components = null;
private InputBox()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.txtData = new System.Windows.Forms.TextBox();
this.lblInfo = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// txtData
//
this.txtData.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
下面一个类实现了类似的InputBox函数的功能:
using System;
using System.Windows.Forms;
namespace Input
{
///
/// clsInputBox 的摘要说明。
///
public class InputBox : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtData;
private System.Windows.Forms.Label lblInfo;
private System.ComponentModel.Container components = null;
private InputBox()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.txtData = new System.Windows.Forms.TextBox();
this.lblInfo = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// txtData
//
this.txtData.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
相关文章
- 修真无限轮回手游轮回世界探索攻略修真无限轮回手游深度轮回机制解析 09-02
- 遮天帝路争锋星空古路探索与通关全流程攻略 09-02
- 末日安全屋血狼势力通关攻略|全阶段任务流程与关键决策指南 09-02
- 末日安全屋晶核快速获取攻略末日安全屋高效刷取晶核的实用做法 09-02
- TPLINK TLWR842+ 无线路由器网速限制设置指南 09-02
- 剑星卢瓦高层全收集如何跑图 09-02