如何修改设计器表单中的列表框或组合框范围 [英] how I Can Modify listbox or combobox Range in Designer Form

查看:119
本文介绍了如何修改设计器表单中的列表框或组合框范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void InitializeComponent()
       {
           this.listBox1 = new System.Windows.Forms.ListBox();
           this.button1 = new System.Windows.Forms.Button();
           this.textBox1 = new System.Windows.Forms.TextBox();
           this.SuspendLayout();
           //
           // listBox1
           //
           this.listBox1.FormattingEnabled = true;
           this.listBox1.Items.AddRange(new object[] {
           "1",
           "2",
           "3",
           "4",
           "5",
           "6"});
           this.listBox1.Location = new System.Drawing.Point(70, 31);
           this.listBox1.Name = "listBox1";
           this.listBox1.Size = new System.Drawing.Size(120, 95);
           this.listBox1.TabIndex = 0;



我想在不保存的情况下将项目添加到ListBox中仅保存在form.Designer.cs的示例中我现在通过收集手动将6个项目添加到listBox中,现在我想从TextBox中添加另一个项目.我该怎么办



I Want Add Item to ListBox Without Saving Just Save in form.Designer.cs foe example I add 6 Item to listBox Manualy via Collection Now I Want Add another Item from TextBox. HOW I CAN DO IT

推荐答案

你是这个意思吗?
Do you mean this?
string strText = textbox1.Text;
listBox1.Items.Add(strText);


首先感谢您的关注;)

我想将项目存储在listBox Whitout中保存在数据库等中
并在重新运行程序后保留数据
我的意思是永远更改程序的来源
first of all thank you for your attention ;)
No
I want to Store Items In listBox Whitout saving in DataBase or etc
and Keep data after rerun the Program
My mean change the Source Of the program fo ever


总之,这是错误的方法.
在不切实际的更改之后,您将不得不让程序重新编译自身.
一种方法是查看序列化或简单地从多行文本文件中读取和写入.
In short, that is the wrong approach.
You would have to get the program to re-compile itself after a change which is not practical.
One approach is to look at serialization or simply read from and write to a multi line text file.


这篇关于如何修改设计器表单中的列表框或组合框范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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