I’m trying to bind a simple one-line string to a textbox’s “text” property but it doesn’t seem to be working. What am I doing wrong?
string loadedFilename;
textBoxFileName.DataBindings.Add("Current File", loadedFilename, "Text");
I just want to show the user which file they’re currently working on using a textbox. I’m using a textbox so that they can copy this string in winforms. (A label won’t do that)
I cannot use an object wrapper because this will cause a cascade of complications down the line in my code. There must be a simple way to do this.
Due to your latest remark about not encapsulating the loadedFilename, I would say: do not use databinding. Instead do it the old fashioned way like
Depending on the flow, you can make it an internal propery in the form-code like so
Or set it in the Form_Load event.
Works everytime.