-3

I'm trying to read my saved configuration settings back into TextBoxes with

txtMailServer.Text = Properties.Settings.Default.MailServer;

But the text box contents are being prefixed with this text in front of the actual value...

System.Windows.Forms.TextBox, Text: the.mail.server

What is causing that?

rene
  • 41,474
  • 78
  • 114
  • 152
M C
  • 61
  • 7
  • How do you save it? What is the current value of the property if you inspect it with a debugger? – Patrick Hofman Feb 06 '17 at 08:17
  • I doubt that it the actual code, also you might have something else you don't show here (unless that's the value you saved). Note: if you persist value using `txtMailServer.ToString()` then it's what you get... – Adriano Repetti Feb 06 '17 at 08:17
  • I just noticed the extra text is being 'saved' into the .config thanks for the idea. Will update... – M C Feb 06 '17 at 08:18
  • 3
    Just don't _save_ with `txtMailServer.ToString()`, use `txtMailServer.Text` instead. – Adriano Repetti Feb 06 '17 at 08:19

1 Answers1

0

OK FIXED - still learning...! I simply needed to tag .Text on the end of the control when I was saving it. I made the assumption the Text attribute would be defaulted - not smart on my part. D'oh

M C
  • 61
  • 7