C# 如何将Form1值发送给其他cs

C# 如何将Form1值发送给其他cs,c#,C#,我知道如何将值Form1发送到Form2,而且效果很好 表格1 public static string sirket = ""; public static string personeladı = ""; public static string desc = ""; public static string toplampay = ""; private void prew_Click(object send

我知道如何将值Form1发送到Form2,而且效果很好

表格1

        public static string sirket = "";
        public static string personeladı = "";
        public static string desc = "";
        public static string toplampay = "";

        private void prew_Click(object sender, EventArgs e)
        {
            List<ListViewItem> myList = new List<ListViewItem>();

            foreach (ListViewItem lvi in this.listView1.Items)
            {
                myList.Add(lvi);
            }

            sirket = companyname.Text;
            personeladı = personelcombo.Text;
            desc = paydesc.Text;
            toplampay = totalpay.Text;

            Form2 frm2 = new Form2(listView1);
            frm2.Show();

        }
我的问题是我有一个表单名Form1,它是一个表单,我写了Listviewprint.cs而不是表单。我想将值Form1发送到Listviewprint.cs,但当我尝试使用上面的方法时,它会给我错误

The name 'Form1' does not exist in the current context.
如何将Form1的值发送到Listviewprint.cs

我不是100%清楚您真正想做什么,但我认为这会对您有所帮助。如果您不清楚,请发表评论

如果您有Form1类,并在其中声明ListViewPrint。之后,您可以在Form1中设置它的公共属性


在哪里实例化ListViewPrint?在Form1或Form2中?取决于Listviewprint.cs中的内容!希望有一个类,并且在代码中的某个地方创建它的实例。。仅仅因为它不是一种形式并不意味着你不能把东西传递给它,但是您必须调用一些变量/方法来在My listviewprint所在的两个数据库之间发送数据Form1@BugFinder请帮我做一下好吗?@DjSucuk我很乐意,但你没有提供足够的信息我的listviewprinter.cs不是Form1我上传了我的解决方案探索者你的listviewprinter对象在哪里?我在我的问题您必须在某处实例化ListViewPrint myLViewPrint=新建ListViewPrint。在哪里创建ListViewPrint的新对象?
The name 'Form1' does not exist in the current context.
public partial class Form1 : Form
{
        private ListViewPrint _mylistviewPrint;

        public Form1()
        {
            InitializeComponent();

            _mylistviewPrint = new _mylistviewPrint(/*or with your parameters*/);
        }

        public void DoSomethingInForm1()
        {
            _mylistviewPrint.SomeVariable = 52;
        }

}

public class ListViewPrint
{
    private int _somevariable;
    public int SomeVariable
    {
        get
        {
            return _somevariable;
        }
        set
        {
            _somevariable = value;
        }
    }

    private string _othervariable;
    /// like the above

}