B
Blip
I am still struggling with a pattern that can be used to move data
from a class to a related form, and from the class method results to
text boxes, listboxes, etc on the form. I usually get it working by
adding enough contructors and instances (but I'm sure that I don't
always point at the form or class instant that I am expecting).
This is frustrating because it should be so simple. BTW, I tried
putting:
Tester t = new Tester(); on the form1 load event, and
Form1 f = new Form1(); at the top of the class the class.
This resulted in an infinite loop. I hope that this code describes my
issue, but if it dowsn't please let me know what you want to see.
Thanks very much for taking some time with this.
tester.cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace Test
{
public class Tester
{
public int total;
public void Foo()
{
string b = "bar"
}
public void Bar() {
{
int i = 0;
int j = 0;
int k = 0;
int m = 0;
int n = 0;
int p = 0;
for (i=0;i<entries<i++)
int sum1 = j + k;
sum2 = m+n+p;
total = sum1 + sum2;
}
Here is the form1.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace Test
public partial class Form1 : Form
{
public Tester t = new Tester();
public Form1()
{
InitializeComponent();
}
private void buttonBegin_Click(object sender, EventArgs e)
{
listBox1.Items.Add(t.b);
}
private void PopulateListBoxFields (string message)
{
listBox1.Items.Add(t.total);
}
}
}
from a class to a related form, and from the class method results to
text boxes, listboxes, etc on the form. I usually get it working by
adding enough contructors and instances (but I'm sure that I don't
always point at the form or class instant that I am expecting).
This is frustrating because it should be so simple. BTW, I tried
putting:
Tester t = new Tester(); on the form1 load event, and
Form1 f = new Form1(); at the top of the class the class.
This resulted in an infinite loop. I hope that this code describes my
issue, but if it dowsn't please let me know what you want to see.
Thanks very much for taking some time with this.
tester.cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace Test
{
public class Tester
{
public int total;
public void Foo()
{
string b = "bar"
}
public void Bar() {
{
int i = 0;
int j = 0;
int k = 0;
int m = 0;
int n = 0;
int p = 0;
for (i=0;i<entries<i++)
int sum1 = j + k;
sum2 = m+n+p;
total = sum1 + sum2;
}
Here is the form1.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace Test
public partial class Form1 : Form
{
public Tester t = new Tester();
public Form1()
{
InitializeComponent();
}
private void buttonBegin_Click(object sender, EventArgs e)
{
listBox1.Items.Add(t.b);
}
private void PopulateListBoxFields (string message)
{
listBox1.Items.Add(t.total);
}
}
}