How to add from one form string to another form list?
1
Expert's answer
2013-06-19T09:23:56-0400
You can’t have direct access from one form to another form data. You must append to your project new class file, for example DataClass.cs. There you need to describe a new static class at the same namespace as your project. Fields of this class must be static too. So you can use this fields to store data from one form and restore in another form. Instance of this class does not declare. You can use it by ClassName.FieldName . Simple example of such class:
Filename DataClass.cs :
using System; using System.Collections.Generic; using System.Text;
namespace project { public static class DataClass { public static string storeData; } }
Now you can use field storeData to do the transfer of data between your forms. For example from textBox1 at Form1 to listBox1 at Form2:
Comments
Leave a comment