By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,723 Members | 1,391 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,723 IT Pros & Developers. It's quick & easy.

help with tabControl confusion please?

P: n/a
cdj
Hi all,

I've got a tabControl, initially with one tabPage, along with two
buttons, one to add another tabPage, and one to delete the current
(selected) tabPage.

On each tabPage, when it is created, is an pictureBox.

Other stuff on the form leads to the creation of a graphic, say
myImage, which I would like to assign to the pictureBox.Image property
of the pictureBox on the currently selected tabPage.

I've tried all sorts of things (and learned a lot about the tabControl
class - lol), but I can't for the life of me figure out how to refer
to: "the pictureBox on the currently-selected tabPage of the
tabControl".

This is a let's-learn-C# project for myself, so any help would be much
appreciated.

Thanks in advance,

cdj
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Are you talking about this?
================================================== ====
private void tabControl1_SelectedIndexChanged(object sender,
System.EventArgs e)

{

tabControl1.SelectedTab.Controls.Add(pictureBox1);

}

================================================== ================

Now in this code if you want to change the image of picture box just change
it before using it.

"cdj" <a_******@hotmail.com> wrote in message
news:b0**************************@posting.google.c om...
Hi all,

I've got a tabControl, initially with one tabPage, along with two
buttons, one to add another tabPage, and one to delete the current
(selected) tabPage.

On each tabPage, when it is created, is an pictureBox.

Other stuff on the form leads to the creation of a graphic, say
myImage, which I would like to assign to the pictureBox.Image property
of the pictureBox on the currently selected tabPage.

I've tried all sorts of things (and learned a lot about the tabControl
class - lol), but I can't for the life of me figure out how to refer
to: "the pictureBox on the currently-selected tabPage of the
tabControl".

This is a let's-learn-C# project for myself, so any help would be much
appreciated.

Thanks in advance,

cdj

Nov 16 '05 #2

P: n/a
cdj
"ISMAILRAJPUT" <hu************@hotmail.com> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl...
Are you talking about this?
================================================== ====
private void tabControl1_SelectedIndexChanged(object sender,
System.EventArgs e)

{

tabControl1.SelectedTab.Controls.Add(pictureBox1);

}

================================================== ================
Not quite - I've already put pictureBoxes on the newly-made
tabPages......... What I need to do now is put a graphic, say myImage, into
the myPicBox.Image property of the pictureBox of the currently selected
tabPage. In other words, I just need a statement of the following form:

(pictureBox control on the currently selected tabPage on the
tabControl).Image = myImage;

Of course, the stuff in parentheses isn't valid c#, which is why I'm
here.... I just don't know how to refer to a control I've created
programmatically.... :(

I've been looking thru the tabControl class library, but I just don't see
what I use from there to make a statement such as the above.

Somewhat more generally, I was hoping to make a variable, to wit
currentPictureBox, which would be updated with the pictureBox on the current
tabPage according to the SelectedIndexChanged event.

thanks for your response though,

cdj
Now in this code if you want to change the image of picture box just change it before using it.

"cdj" <a_******@hotmail.com> wrote in message
news:b0**************************@posting.google.c om...
Hi all,

I've got a tabControl, initially with one tabPage, along with two
buttons, one to add another tabPage, and one to delete the current
(selected) tabPage.

On each tabPage, when it is created, is an pictureBox.

Other stuff on the form leads to the creation of a graphic, say
myImage, which I would like to assign to the pictureBox.Image property
of the pictureBox on the currently selected tabPage.

I've tried all sorts of things (and learned a lot about the tabControl
class - lol), but I can't for the life of me figure out how to refer
to: "the pictureBox on the currently-selected tabPage of the
tabControl".

This is a let's-learn-C# project for myself, so any help would be much
appreciated.

Thanks in advance,

cdj


Nov 16 '05 #3

P: n/a
here is another way
================================================== =======

private void tabControl1_SelectedIndexChanged(object sender,
System.EventArgs e)

{

pictureBox1.Image = System.Drawing.Image.FromFile("C:\\goldepic2.jpg") ;

tabControl1.SelectedTab.Controls.Add(pictureBox1);

}

================================================== ===================

"cdj" <sh*************@hotmail.com> wrote in message
news:uf*************@TK2MSFTNGP11.phx.gbl...
"ISMAILRAJPUT" <hu************@hotmail.com> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl...
Are you talking about this?
================================================== ====
private void tabControl1_SelectedIndexChanged(object sender,
System.EventArgs e)

{

tabControl1.SelectedTab.Controls.Add(pictureBox1);

}

================================================== ================
Not quite - I've already put pictureBoxes on the newly-made
tabPages......... What I need to do now is put a graphic, say myImage,

into the myPicBox.Image property of the pictureBox of the currently selected
tabPage. In other words, I just need a statement of the following form:

(pictureBox control on the currently selected tabPage on the
tabControl).Image = myImage;

Of course, the stuff in parentheses isn't valid c#, which is why I'm
here.... I just don't know how to refer to a control I've created
programmatically.... :(

I've been looking thru the tabControl class library, but I just don't see
what I use from there to make a statement such as the above.

Somewhat more generally, I was hoping to make a variable, to wit
currentPictureBox, which would be updated with the pictureBox on the current tabPage according to the SelectedIndexChanged event.

thanks for your response though,

cdj
Now in this code if you want to change the image of picture box just

change
it before using it.

"cdj" <a_******@hotmail.com> wrote in message
news:b0**************************@posting.google.c om...
Hi all,

I've got a tabControl, initially with one tabPage, along with two
buttons, one to add another tabPage, and one to delete the current
(selected) tabPage.

On each tabPage, when it is created, is an pictureBox.

Other stuff on the form leads to the creation of a graphic, say
myImage, which I would like to assign to the pictureBox.Image property
of the pictureBox on the currently selected tabPage.

I've tried all sorts of things (and learned a lot about the tabControl
class - lol), but I can't for the life of me figure out how to refer
to: "the pictureBox on the currently-selected tabPage of the
tabControl".

This is a let's-learn-C# project for myself, so any help would be much
appreciated.

Thanks in advance,

cdj



Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.