Thursday, 22 August 2013

Not generating new labels in Winforms

Not generating new labels in Winforms

I've been doing plenty of programming (mainly perl and R) but have
recently gotten into C# for creating some Windows Forms programs.
I have created a program that 1) opens a csv 2)Finds all rows where the
first column value is 0, 3)Outputs another column from those rows to a
message box.
I'm trying to switch this over to instead create a label with the other
column value on the form.
Can I get any help with this?
Below is my code:
string [] readText=File.ReadAllLines(file);
int linenum=0;
foreach (string s in readText)
{
string[] values = s.Split(',');
string analyzed1 = values[0];
//if (analyzed1 is string)
//{
int number = Convert.ToInt32(analyzed1);
//linenum++;
if (number == 0)
{
string sample = values[1];
int y = button1.Bottom + (10 * linenum);
Point mypoint = new Point(100, y);
Label lab = new Label();
lab.Location = mypoint;
lab.Text = sample;
this.Controls.Add(lab);
linenum++;
}
}

1 comment: