Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

ModalWindow Referencing Opening Window

$
0
0
I have a form "fUpdateBall". On this form, the user enters as much of the
ball's information as they know. It goes out to the database and if there
are more than one ball that match the criteria (after all, you can have a
logo ball on different colored balls, so they are technically two different
balls), a
new form, fChooseBall is opened:
//----------------------------------------------------------
// Display Popup To Let User Select The Record To Edit
//----------------------------------------------------------
fChooseBall choose = new fChooseBall(golfBalls);
choose.Show();
choose.TopMost = true;
break;

On fChooseBall, there is a routine to click through the various balls to
find the one you want. This part is not an issue, but once I find the ball
I want to update, I click the "Use Current" button, which is supposed to
load the "fUpdateBall" form with this ball's information.

However: I can't seem to figure this part out. How can I get fChooseBall
to update the data element objects on fUpdateBall? I tried to set the
".Parent" propertylike such:
fChooseBall choose = new fChooseBall(golfBalls);
choose.Show();
choose.Parent = this;
choose.TopMost = true;
break;

And then do this in fChooseBall:
TextBox logoName = (TextBox)Parent.Controls["tbLogoName"];

But as you can guess, this doesn't work as I get an error on line:
choose.Parent = this;


And if I remove it, I can't reference the controls on the parent.

I have seen a few articles that say I should create public properties on
fUpdateBall and call those, but I also saw a few articles that say I should
not do this for a variety of reasons.

So could anyone help and let me know the proper way to handle this? Should
I expose some public properties? Even though this is just for personal use,
I would like to do it the correct way in the event I have to do this for my
job, I already have the knowledge.

Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>