I have a form MainForm and a form form1, declared like this:
namespace SdkDemo
{
public partial class MainForm : Form
{
public CoreWrapper _icCore;
private Dictionary<string, int> audioDevices;
#region MainForm Ctor
public MainForm()
{
InitializeComponent();
_icCore.Start();
}
public Form1 form1 = new Form1();
}
}
So form1 is just created with Visual Studio tools.
The whole code of form1:
namespace SdkDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string dial = Registry.CurrentUser.OpenSubKey("SOFTWARE").OpenSubKey("CS").GetValue("DIAL").ToString();
// Error "An object reference is expected":
MainForm.txtSendKeys.Text = ("esdcze");
}
}
}
The problem is that an object reference error appears when i try to call something in "Mainform". Of course, the txtSendKeys
field is public.
BTW, I can easily do the reverse action, which is to do something like
MainForm.textField = x
from my form1.
I seriously lack of knowledge about C#, but this one is for my work and I start to desperate by now..