如何更改文本框中的值而不替换以前的值 [英] how to change values in a textbox without replacing the previous values

查看:75
本文介绍了如何更改文本框中的值而不替换以前的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有文本框的表单,文本框会在表单加载时动态加载。我需要为文本框分配多个值,而不是在加载表单时替换以前的值。例如:我有2个项目,当我点击表格加载的第一个项目,我在文本框中输入45然后我点击第二个项目表格再次加载,我在文本框中输入54现在当我去第一个项目并加载文本框我希望值为45,不应该替换为54 ..我该怎么做?

i有一个扩展器,当我拖动时有几个图标并将一个项目从它拖放到画布上弹出一个窗口,要求我为该项目分配一个值。在右键单击画布上的项目时,会出现另一个窗口,显示在上一个弹出窗体中输入的值。如果我从扩展器再次拖动相同类型的图标,则会发生相同的过程,但第一个图标的值将被新输入的值替换



< br $>
编辑:来自评论:



i have a form with a textbox and the text box gets dynamicaly loaded on the form load. i need to assign multiple values to the textbox without replacing the previous values when ever the form is loaded. for example: i have 2 items when i click on the first item the form gets loaded and i enter 45 in the textbox and then i click the second item the form again gets loaded and i enter 54 in the textbox and now when i go to the first item and load the textbox i want the value to be 45 and shouldn't be replaced with 54.. how do i do this??
i have an expander and several icons in it when i drag and drop an item from it to a canvas a pop up window comes asking me to assign a value for the item. on right clicking the item on the canvas another window comes up showing the value that has been entered in the previous pop up form. and if i drag an drop the same kind of icon again from the expander the same procedure happens but the value of the first icon gets replaced by the newly entered value


From Comments:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace MotionControl.PropertiesForms
{
public partial class property : Form
{
instance inst;
Micropositionclass micro;

public property()
{
InitializeComponent();
micro = Micropositionclass.Instance;

inst = instance.Instance;
if(inst.firstGuidList.Contains(inst.a))
{
this.Text = "MPC1";

}

else if (inst.secondGuidList.Contains(inst.a))
{

this.Text = "MPC2";


}


else if (inst.thirdGuidList.Contains(inst.a))
{
this.Text = "MPC3";

}
else if (inst.fourthGuidList.Contains(inst.a))
{
this.Text = "MPC4";

//MPC.Default.Save();
}
else if (inst.fifthGuidList.Contains(inst.a))
{
this.Text = "MPC5";

//MPC.Default.Save();
}
else if (inst.sixthGuidList.Contains(inst.a))
{
this.Text = "MPC6";

//MPC.Default.Save();
}
else if (inst.seventhGuidList.Contains(inst.a))
{
this.Text ="MPC7";

//MPC.Default.Save();
}
else if (inst.eighthGuidList.Contains(inst.a))
{
this.Text = "MPC8";


//MPC.Default.Save();
}
else if (inst.ninthGuidList.Contains(inst.a))
{
this.Text = "MPC9";

//MPC.Default.Save();
}
else if (inst.tenthGuidList.Contains(inst.a))
{
this.Text = "MPC10";

//MPC.Default.Save();
}
switch (inst.tooltip)
{
case "Move":
this.Size= new Size(238,226);
Label lbl1 = new Label();
lbl1.Text = "X";
lbl1.Location = new Point(15, 35);
lbl1.Size = new Size(14, 13);
Controls.Add(lbl1);
Label lbl2 = new Label();
lbl2.Text = "Y";
lbl2.Location = new Point(15, 70);
lbl2.Size = new Size(14, 13);
Controls.Add(lbl2);
Label lbl3 = new Label();
lbl3.Text = "Z";
lbl3.Location = new Point(15, 105);
lbl3.Size = new Size(14, 13);
Controls.Add(lbl3);
TextBox tb1 = new TextBox();
tb1.Text = micro.movex.ToString();

tb1.Location = new Point(105, 35);
tb1.Size = new Size(100, 20);
Controls.Add(tb1);
TextBox tb2 = new TextBox();
tb2.Text = micro.movey.ToString();
tb2.Location = new Point(105, 70);
tb2.Size = new Size(100, 20);
Controls.Add(tb2);
TextBox tb3 = new TextBox();
tb3.Text = micro.movez.ToString();
tb3.Location = new Point(105, 105);
tb3.Size = new Size(100, 20);
Controls.Add(tb3);
break;
case "Speed":
this.Size = new Size(220, 162);
Label speed = new Label();
speed.Text = "Speed";
speed.Location = new Point(20, 40);

推荐答案

您必须为第二个(以及每个后续)调用构建一个新实例。

你在做什么(我的解释)是一种Messagebox或Dialog。
You have to build a new Instance for the second (and each following) call.
What you are doing (my interpretion) is a kind of Messagebox or Dialog.


这篇关于如何更改文本框中的值而不替换以前的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆