Re: Initializing form (dialog)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows 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.
.



Relevant Pages

  • Re: Initializing form (dialog)
    ... reality I have much more controls. ... parent form has some buttons. ... child form based on the info from the parent? ... someother function in between constructor and dlg.ShowDialog? ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Repost: Controls are unreachable after scroll and form resize.
    ... form are visible and there is no scroll bars on the panel. ... some of the controls on the panel are placed ... Then if I resize the child form to the previous size ... the same as the locations after I drag the scroll bar just now. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Child Windows
    ... > child Form is open, or is it acceptable to open the child Form in a modal ... >> the main window and interact between them. ... >> create my Options window as a new Form object and create it and show it ... >> my child form make changes directly to the controls on the master form - ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Please help: Serious problems with code generation of user controls
    ... IContainer constructor in a derived control alone does not yield the ... controls because the user controls in my last posted example are completed ... System.Diagnostics.Debugger.Launchin the constructor of the inner user ... the first time you instance a problematic UserControl ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)
  • Re: Creating A Window
    ... windows because it doesn't know where they are going to be. ... The CDialog constructor already gets passes a resource handle to a dialogue ... were to actually do the instantiation, the windows of the controls all had to be created ...
    (microsoft.public.vc.mfc)