Hi all.
I'm learning VB.Net and am developing a WinForms app.
I'm trying to make an app that I will use to scan in one or more than
on image. I want to use a tabbed interface to hold each image. Here's
the code I'm using for testing purposes. I've got the code in the
form's load event, but I think I'd have the same problems no matter
where the code existed. Right now, the form has an empty tab control,
everthing else is dynamic.
<code>
//Create a new tab
TabPage tabPage1 = new TabPage();
//Create a new panel
Panel panel1 = new Panel();
//add the panel to the form;
this.Controls.A dd(panel1);
//create a new Picturebox;
PictureBox pictureBox1 = new PictureBox();
tabPage1.Text = "Page1";
//add the tab to the tab control;
this.tabImageHo lder.Controls.A dd(tabPage1);
//add the panel to the tab
tabPage1.Contro ls.Add(panel1);
//add the picturebox
panel1.Controls .Add(pictureBox 1);
panel1.AutoScro ll = true;
panel1.Dock = System.Windows. Forms.DockStyle .Fill;
pictureBox1.Siz eMode = PictureBoxSizeM ode.AutoSize;
pictureBox1.Ima ge = new Bitmap(@"C:\Ima geStreamer1.gif ");
</code>
My problem, besides ignorance, is that I now can't reference any of
the controls I've created anywhere else in the form. I think I
understand why, because the controls have been created on the fly and
are scoped to the Load event, right? If so, is there anyway I can make
these dynamic controls be "global" to the rest of the methods in the
form's class? Thanks.
I'm learning VB.Net and am developing a WinForms app.
I'm trying to make an app that I will use to scan in one or more than
on image. I want to use a tabbed interface to hold each image. Here's
the code I'm using for testing purposes. I've got the code in the
form's load event, but I think I'd have the same problems no matter
where the code existed. Right now, the form has an empty tab control,
everthing else is dynamic.
<code>
//Create a new tab
TabPage tabPage1 = new TabPage();
//Create a new panel
Panel panel1 = new Panel();
//add the panel to the form;
this.Controls.A dd(panel1);
//create a new Picturebox;
PictureBox pictureBox1 = new PictureBox();
tabPage1.Text = "Page1";
//add the tab to the tab control;
this.tabImageHo lder.Controls.A dd(tabPage1);
//add the panel to the tab
tabPage1.Contro ls.Add(panel1);
//add the picturebox
panel1.Controls .Add(pictureBox 1);
panel1.AutoScro ll = true;
panel1.Dock = System.Windows. Forms.DockStyle .Fill;
pictureBox1.Siz eMode = PictureBoxSizeM ode.AutoSize;
pictureBox1.Ima ge = new Bitmap(@"C:\Ima geStreamer1.gif ");
</code>
My problem, besides ignorance, is that I now can't reference any of
the controls I've created anywhere else in the form. I think I
understand why, because the controls have been created on the fly and
are scoped to the Load event, right? If so, is there anyway I can make
these dynamic controls be "global" to the rest of the methods in the
form's class? Thanks.
Comment