The title of my question seems simpler then my problem really is. What I am doing is trying to put a string into my textbox, but it won't go in. I'm doing this by passing the string from one class to another and then another. Sort of trickling down the ladder so to speak. The string starts here:
public static void FilePath(string fileName)
{
string fn = fileName;
PicForm.FileName(fn);
}
fileName
is being pulled from a saveFileDialog
by way of FilePath(sd.FileName)
. It then moves to PicForm.FileName()
, which looks like this:
public static void FileName(string fileName)
{
string fn = fileName;
AddAtt aa = new AddAtt(Form1.con);
aa.AddScan(fn);
}
From there it is sent to aa.AddScan()
, which looks like this:
public void AddScan(string fileName)
{
textBox7.Text = fileName;
}
Clearly this is were the string is to be entered into the textbox, but it doesn't. Now I've added MessageBoxes to check to make sure that the sting is making it to here and that the textBox7.Text is being set to the string(fileName) properly. And the MessageBoxes show that the code works. But the textbox says differently. I've also tried a different way of using AddScan(). I added it to another button that uses an openFileDialog. And that looks like this:
private void button3_Click(object sender, EventArgs e)
{
string Chosen_File = "";
openFileDialog1.InitialDirectory = "C:";
openFileDialog1.FileName = "";
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
{
MessageBox.Show("Operation Cancelled");
}
else
{
Chosen_File = openFileDialog1.FileName;
//textBox7.Text = Chosen_File;
AddScan(Chosen_File);
}
}
Now when I call AddScan()
from that click event, the textBox7 displays the text properly. My question is why does it work one way but not the other. It seems to me that the code should work. Any help would be great.