此程式码是网路上找来别人写好的C# InputBox Funtion Code,只是我看不大懂,例如我今天输入一个字串,那他会存在哪个记忆体位置?还有如果我要增加一个当按下Enter时跟按下btnOK一样的动作时要怎么写?
问题还很多一时问不清楚ˊˋ,初学者,请见谅
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication1
{
#region InputBox return result
/// <summary>
/// Class used to store the result of an InputBox.Show message.
/// </summary>
public class InputBoxResult
{
public DialogResult ReturnCode;
public string Text;
}
#endregion
/// <summary>
/// Summary description for InputBox.
/// </summary>
public class InputBox
{
#region Private Windows Contols and Constructor
// Create a new instance of the form.
private static Form frmInputDialog;
private static Label lblPrompt;
private static Button btnOK;
private static Button btnCancel;
private static TextBox txtInput;
public InputBox()
{
}
#endregion
#region Private Variables
private static string _formCaption = string.Empty;
private static string _formPrompt = string.Empty;
private static InputBoxResult _outputResponse = new InputBoxResult();
private static string _defaultValue = string.Empty;
private static int _xPos = -1;
private static int _yPos = -1;
#endregion
#region Windows Form code
private static void InitializeComponent()
{
// Create a new instance of the form.
frmInputDialog = new Form();
lblPrompt = new Label();
btnOK = new Button();
btnCancel = new Button();
txtInput = new TextBox();
frmInputDialog.SuspendLayout();
//
// lblPrompt
//
lblPrompt.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
lblPrompt.BackColor = SystemColors.Control;
lblPrompt.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((Byte)(0)));
lblPrompt.Location = new Point(12, 9);
lblPrompt.Name = "lblPrompt";
lblPrompt.Size = new Size(302, 82);
lblPrompt.TabIndex = 3;
//
// btnOK
//
btnOK.DialogResult = DialogResult.OK;
btnOK.FlatStyle = FlatStyle.Popup;
btnOK.Location = new Point(326, 8);
btnOK.Name = "btnOK";
btnOK.Size = new Size(64, 24);
btnOK.TabIndex = 1;
btnOK.Text = "&OK";
btnOK.Click += new EventHandler(btnOK_Click);
//
// btnCancel
//
btnCancel.DialogResult = DialogResult.Cancel;
btnCancel.FlatStyle = FlatStyle ..
访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容