I use OpenFileDialog to open and read a file into my application to display specific data. I have multiple Forms - 2/3 of which I need to be able to display the value that is read from the file into a label. At the moment, I have just hard-coded some data into a label and using a Get Set method, I am able to get the value. However, when I have tried to get the label value when data is populated from a file, nothing returns.
internal string GetSetBarcode
{
get
{
// Barcode label
return this.label36.Text;
}
private set
{
this.label36.Text = value;
}
}
// Currently working on a new method to populate data more appropriately as this is not the best, but it works for now.
string result = System.Text.Encoding.UTF8.GetString(box);
string r = Regex.Replace(result, "[^a-zA-Z0-9 .-]", string.Empty);
for (int i = 0; i < r.Length; i++)
{
for (int b = 11; i < b; i++) // Product Code
{
label7.Text += r[i];
}
}
Form1 f1 = new Form1();
MessageBox.Show(f1.GetSetBarcode); // For testing purposes... But this returns 0 :(
I managed to come up with a solution, see https://stackoverflow.com/a/21310270/2952390 (answer to a related question I asked previously). Here it retrieves text from a combobox to a label on another form. Much easier than I thought it would be.