Programmatically get printPreviewDialog on a windows form

  • Thread starter Thread starter inpuarg
  • Start date Start date
I

inpuarg

I have a windows form, there are button , textbox label etc. controls
on it. and i can programmatically get each of their names. and i also
have a printPreviewDialog on a form.
I cannot get it through loop.
i know that it does not have an appearance.
so - how can i get it programmatically ?



private void button1_Click(object sender, EventArgs e)
{
this.listBox1.Items.Clear();
ApplySomething(this);
}

internal void ApplySomething(Control c)
{
try
{
this.listBox1.Items.Add(c.Name);
if (c.HasChildren)
{
foreach (Control childControl in c.Controls)
{
ApplySomething(childControl);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
 
I think i can reach via reflection.
Cause printPreviewDialog is not a control , a member.
 
Back
Top