1
Answer

NullReferenceException

Ask a question
aapt.temp

aapt.temp

19y
1.8k
1
Hi, I need to print my form on a printer, that is all values from the textboxes, comboboxes etc. preferrably in a graphical manner. I found an example on the internet to print out textboxes which has the following code: for (int i = 0; i < this.Controls.Count; i++){ if (this.Controls[i] is TextBox) g.DrawString(this.Controls[i].Text, this.Controls[i].Font, Brushes.Black, this.Controls[i].Bounds.Left*scalex, this.Controls[i].Bounds.Top * scaley, new StringFormat()); } But no matter what I tried it always throws a NullReferenceException. Could anyone please tell me what's the matter with it, I'm just clueless. Or could anyone please give me another example or point me to a tutorial or anything. I've been struggling with the printing for a few days now and nothing seems to work. Thanks a lot.

Answers (1)