I've GUI with several Labels, Listboxes, NumericUpDown etc. I want read their values in another class. Standard properties of controls are private. How should I do this?
I believe the most appropriate way to do it would be to encapsulate these GUI elements into properties and expose their data via a getter. e.g.
public string SomeLabelValue
{
get { return label1.Text;}
}
This protects your element to only being read, while exposing the least amount of data from your object.
You can however expose the entire element and/or allow a setter method to change the values of the element if applicable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With