Re: Initializing form (dialog)

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Alex wrote:
DH, thanks for the reply. But the example I gave is very simple, in
reality I have much more controls. To have a constructor with twenty
parameters seems a little bit odd to me. So there is nothing like
OnInitDialog() indeed?

Thanks again,
Alex

On Dec 17, 4:44 pm, DH <I.dont.n...@xxxxxxxxx> wrote:
Alex wrote:
Hello everybody,
I'm just starting C#. I'm working on forms based application. The
parent form has some buttons. If I click the button, some child form
must pop-up. My question is - is there in C# something analogous to
OnInitDialog from C++? So I'm able to initialize controls in the
child form based on the info from the parent?
I have:
private void btSomeButton_Click(object sender, EventArgs e)
{
SomeChildDlg dlg = new SomeChildDlg();
dlg.m_strValueForControl1 = "aaaaaa";
dlg.m_strValueForControl2 = "xxxxxx";
if (dlg.ShowDialog() == DialogResult.OK)
......................................................
..............................
But how at the very beginning can I populate controls in my
SomeChildDlg form (put string "aaaaaa" in one text box on child form
and assing "xxxxxx" to another text box) ? Do I have to call
someother function in between constructor and dlg.ShowDialog()?
Thanks,
Alex
Alex,
If you are just going to be populating controls with some value you
could create a constructor that takes them as a parameter of some sort.
DH- Hide quoted text -

- Show quoted text -

Alex,
I havnt done C++ programming like this. But you could pass it as a class of some type to the constructor i would imagine and just enumerate the properties.
I'm doing something similar but my requirements are very tight and the data i need is written to a XML each time and I just pass it the XML data.
.


Quantcast